In my WordPress site I want to prevent any uncategorized posts from showing up in site searches and in archive pages – including the front page of recent posts.
The only places that I want uncategorised posts to be visible are the actual posts themselves, and on the author archive pages, eg example.com/author/authorName
I have looked in vain for a plugin. I reckon there must be some custom php, but my skills are not that deep.
Any help or clues greatly appreciated!
You have to exclude the category from the loop in your
archive.php
andindex.php
. This example uses category ID numbers, which you can find by going to Posts >> Categories. You’ll see the ID for each category.In your files mentioned above, find the loop
As for the search results, try this. This will go in
functions.php
(I haven’t tested it so let me know if there are issues).Please note: you can also comma separate the categories here by doing this: