Today I want to talk about a neat little tip for hiding or displaying certain pages from your WordPress blog or site's navigation menu. It's really quite simple, and very handy if you don't know how to do it already.
Here is the line of code that is either already inserted somewhere in your WordPress template files (most likely the header.php file) or needs to be added to your WordPress template files in order to display the list of your website's pages:
This line of code displays every single one of the website's pages that you have created in your WordPress admin panel. But suppose you don't want three of the pages to be displayed in the main navigation? How do you control which pages are displayed and which are not?
All you need to do is simply add to the code mentioned above. We are going to add the page IDs that you want to exclude.
(Note: You can find the page or post IDs by going to the list of pages or posts in your WordPress admin panel. Hover your mouse cursor over the page or post titles and look at the status bar at the bottom of your screen. The ID number is the number at the very end of the link that shows. Leave a comment below if that is not clear and you need more help.)
Now that you know which page or post IDs you plan to exclude, add the numbers to your code, like the example below:
And that's all there is to it! Now the pages that you want to hide from the navigation menu will not be displayed.
Now - if there are more pages to exclude than to include, you may want to do this the other way around. Add this line of code to define the only pages that you want to display in the navigation menu:
So, there you go - a very easy way to control which pages do and don't display in your WordPress navigation menus! Let me know if you have any questions or need further help or explanation.
Niciun comentariu:
Trimiteți un comentariu