原谅我的新手——对于更有经验的人来说,这可能是一件非常简单的事情。我试图搜索论坛,但没有找到合适的解决方案。
我试图使我的Wordpress菜单添加自定义标题到当前菜单项上的特定帖子类型时,该页面是活动的,什么是最好的方法这样做?
Menu <--- Original menu item<br>
Menu: Addition <--- When on the custom post type titled "Addition"
有什么想法吗?
我将首先在呈现菜单的模板(主题)中查找代码。您需要查找呈现导航菜单的函数wp\u nav\u menu()
:https://developer.wordpress.org/reference/functions/wp_nav_menu/
根据您想要选择的检查帖子类型的解决方案有多复杂,我建议使用简单的if()语句。
要检查帖子类型,可以使用get\u post\u type()
:https://developer.wordpress.org/reference/functions/get_post_type/
如果post type是"附加",则将参数传递到wp_nav_menu()
以使用自定义菜单为该post type做好准备。