Excuse my rookieness – this might be a very simple thing to solve for someone with more experience. I tried searching the forum but did not find a fitting solution.
I am trying to make my Wordpress menu add the custom title to a current menu item on a specific post type when that page is active, what would be the best way to do so?
Menu <--- Original menu item<br>
Menu: Addition <--- When on the custom post type titled "Addition"
Any ideas?
I would start with finding the code in the template ( theme ) where menu is being rendered. You need to look for function that renders navigation menu wp_nav_menu()
: https://developer.wordpress.org/reference/functions/wp_nav_menu/
Depending on how complicated solution you want to choose to pick for checking the post type - I would suggest simple if()
statement.
To check post type you can use get_post_type()
: https://developer.wordpress.org/reference/functions/get_post_type/
If post type is "Addition" pass argument to wp_nav_menu()
to use custom menu prepare for that post type.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.