wp_get_nav_menu_items() current menu item
When displaying a menu in WordPress I sometimes find it pleasant to use the wp_get_nav_menu_items() function. This function returns only an array of menu item objects of the corresponding menu. So it allows you to build your custom menu exactly the way you want, without dealing with WordPress predefined output. However, if you would use the function wp_nav_menu() you benefit […]
Get nav menu items by location
WordPress default get_nav_menu_items() function uses the menu name as identifier to retrieve the right menu items. I think it is better to retrieve the menu items by location since the menu name is a value which can be changed in the database and the location is hardcoded in your functions.php file by registering the menu.
Check if page is in menu
With the following function you can check if a page is in a certain menu.
Next previous link in menu
In some cases you need to know the next and previous url of your current post in a WordPress menu. For example if you want to build a multiple step form or wizard application based on a WordPress menu. The function below takes the menu name as a parameter and uses the global $post object to […]