By default WordPress pushes out a whole array of pages I donât want or need – archive, author, blog, monthly, recent posts, categories, comments, attachment, taxenomies, search, search results, and probably a few others Iâve missed.
Most of the time Iâm building regular broshure websites with no need for anything except a few fairly static pages. How do I get rid of all the other pages? Is there a plugin that will do this? Do I have to set up a dozen redirects in the .htaccess? Iâve tried searching, but all I find is how to hide parts of a page, or customise the sitemap to hide from searches. But I don’t want those pages at all, so even entering the direct URL shouldn’t work.
You could redirect anything that’s not a page or admin to home via the
parse_query
action:If it’s not an admin screen or a query for a page, it’ll redirect. You can see all of the types of pages this will remove under the Conditional Tags page in Codex.
Joost de Valk’s WordPress SEO plugin is capable of disabling most, if not all, archives you mention:
You can user another small script, without adding any plugin. There is a post here and the code to add in the index.php of your theme is this:
Hope you find it useful.
For anyone wondering, I ended up using .htaccess 301 redirects.
The blogpost archive
^/20.*$
isn’t ideal, but it will have to do for now. Also don’t know what other pages I might’ve missed.It can also be achieved using the template_redirect hook.
You can check for each type of archives pages, or “disable” them altogether.
In
functions.php
: