nav_menu_link_attributes

過濾鉤子
apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth )
引數
  • (array) $atts { The HTML attributes applied to the menu item's `<a>` element, empty strings are ignored. @type string $title Title attribute. @type string $target Target attribute. @type string $rel The rel attribute. @type string $href The href attribute. @type string $aria-current The aria-current attribute. }
    Required:
  • (WP_Post) $menu_item The current menu item object.
    Required:
  • (stdClass) $args An object of wp_nav_menu() arguments.
    Required:
  • (int) $depth Depth of menu item. Used for padding.
    Required:
定義位置
相關勾子
page_menu_link_attributesnext_comments_link_attributesprevious_comments_link_attributescomments_popup_link_attributesnext_posts_link_attributes
相關方法
get_language_attributeswp_pre_kses_block_attributesget_nav_menu_locationsserialize_block_attributesis_nav_menu_itemlanguage_attributes
引入
4.1.0
棄用
-

nav_menu_link_attributes: 這個過濾鉤子用於過濾導航選單項中連結元素的HTML屬性。該鉤子接收屬性作為一個引數,並返回過濾後的屬性。

過濾應用於選單項錨定元素的HTML屬性。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );
$atts = apply_filters( 'nav_menu_link_attributes', $atts, $menu_item, $args, $depth );

常見問題

FAQs
檢視更多 >