Filters a navigation menu item object.
Parameters
$menu_item
object- The menu item object.
Source
return apply_filters( 'wp_setup_nav_menu_item', $menu_item );
Changelog
Version | Description |
---|---|
3.0.0 | Introduced. |
Filters a navigation menu item object.
$menu_item
objectreturn apply_filters( 'wp_setup_nav_menu_item', $menu_item );
Version | Description |
---|---|
3.0.0 | Introduced. |
You must log in before being able to contribute a note or feedback.
In some cases when using WordPress for application development, you might need to change the url structure of a page url in the nav menu to reflect your routing setup to maintain an app-like state.
In this example, we want to filter all nav menu links in the menu item object that are pages, and change them from the default
http://example.com/target-page/
to a prefixed slug like/pages/target-page/
to meet out routing needs. To do this, filter the menu item object like so: