This PHP code enables you to change the primary nav menu for any permalink slug or i.d.
1. primary – This is the Theme Location the default menu is assigned to. Go to Appearance > Menus > Manage Locations to configure this setting.
2. default – This is the name of the menu. Go to Appearance > Menus > Edit Menus to create a menu named default.
3. about – This is the permalink slug for the page named About. You can use the slug for any other page or the post/page/tag slug in its place. You can also change the conditional tag to any other.
4. custom – This is the name of the conditional menu which you can create. Go to Appearance > Menus > Edit Menus to create a menu named custom. When you click on the menu item named about, the menu with the name custom will display rather than the menu named default.
The code also includes the PHP comparison operator == and the basic assignment operator = which is used to write a value to a variable.
Hope you find this code and tutorial useful and and look forward to any questions you may have about this topic in the comments below.
Leave a Reply
You must be logged in to post a comment.