WordPress automatically assigns the default category to a single page. This is a simple way to exclude certain pages, for example, a contacts page, from displaying in your search results. A simple way around this is to create a new category, in this instance I have called it pages. Once the category is created hover over the newly created category and look for the cat-ID number as shown below, remember it or write it down.
Then we need to change the default category setting so go to Settings>Writing in your admin panel and change the default category to the newly created one. The only problem is now is that if your pages have already been published they have already been assigned a category so you will have to re-publish them. Create a new page then copy and paste all the old stuff into the new page, delete the old page and save the new page. This will then assign your new default category to your page.
Now in our search.php type the following under get_header()
Replace the number with the one you wrote down but keep the minus (-) in there as this excludes the category from displaying. Your custom pages will not show up in your search page again.
Welcome to Hot Web Dev October 2024, featuring the latest technology and web development news.… Read More
In this tutorial, you’ll build a fun and interactive guessing game using Svelte 5, the… Read More
Welcome to Hot Web Dev September 2024, featuring the latest technology and web development news.… Read More
The JavaScript guessing game tutorial is a simple beginner's project. It features modern JavaScript syntax… Read More
If you have been following the monthly Hot Web Dev magazine you will find the… Read More
Welcome to Hot Web Dev August 2024, featuring the latest technology and web development news.… Read More