Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

3 Answers 3

up vote 3 down vote accepted

You could redirect anything that's not a page or admin to home via the parse_query action:

function wpa_parse_query( $query ){
    if( ! is_admin() && ! $query->is_page() ) {
        wp_redirect( home_url() );
        exit;
    }
}
add_action( 'parse_query', 'wpa_parse_query' );

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.

share|improve this answer

Joost de Valk's WordPress SEO plugin is capable of disabling most, if not all, archives you mention:

enter image description here

share|improve this answer

For anyone wondering, I ended up using .htaccess 301 redirects.

# Redirect useless pages
Options +FollowSymlinks
RewriteEngine on
RedirectMatch 301 ^/portfolio/.*$ /gallery/
RedirectMatch 301 ^/author/.*$ /
RedirectMatch 301 ^/category/.*$ /
RedirectMatch 301 ^/tag/.*$ /
RedirectMatch 301 ^/20.*$ /

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.