On www.webhostingbreak.com I have custom post types for web hosting companies. Their url is /hosting-directory/ and unfortunately, since then (aug2010), we've still got all those pages at PR0 and rankings overall have been terrible.

The only guess I have is that because visiting /hosting-directory/ causes a 404 error, Google might not see pagerank flowing from the root domain to a subpage of hosting-directory.

We want to remove /hosting-directory/ altogether. We tried doing that but we couldn't get normal posts in a category to work.

Is there any workaround for this? Custom post types destroyed our rankings and pagerank since august 2010.

Be well and talk soon.

  • 1
    Why not add in an index page for your custom post types? That way the page won't 404 and it might even be useful for your visitors. Mar 24, 2011 at 1:52
  • I did this tonight. Thanks for the helpful input - it's good to do but I feel Google will never rank my urls with /hosting-directory/ the same as without. I can't believe the results i'm seeing in SERPS... all my custom post type pages rank badly compared to a page that is only 1 level deep in the url structure
    – user4169
    Mar 24, 2011 at 7:28

2 Answers 2


If you want to remove the slug you need to do one of two (2) things:

  1. Stop using custom post types because you don't seem to understand what they are or are meant to be used for. Use pages instead. They already do EXACTLY what you want to do, permalinks-wise.

  2. Add a custom rewrite rule for each and every individual 'hosting company' added in the admin like this:

    add_rewrite_rule('(the-post-slug)/?$','index.php?<post type>=$matches[1]','top');

    You should add this to your theme's functions.php file or in a plugin; I'd suggest a mu-plugin, personally. You could even automate this programmatically, but that would end up costing an extra database query per page load. Just make sure you don't run those before the 'setup_theme' hook (the rewrite API isn't initialized before that hook). Hooking on 'init' would be plenty safe.

    Then you would have to flush the rewrite rules by going to /wp-admin/options-permalinks.php (just visiting the page is enough.)

  • Thank you for the answer - I'm not sure how to use that rewrite rule in my .htaccess - it looks like PHP. I'm not sure what you mean by added in the admin. Is there somewhere I can add custom rewrite rules in WP admin? Is that a 3.1 thing? I'm 3.0 still.
    – user4169
    Mar 24, 2011 at 8:05
  • Sorry for the ambiguity. It is PHP, using WordPress' rewrite api. Answer to be edited above. Mar 24, 2011 at 12:29

Another way to achieve this is by making your plugin with hooks like:

add_filter( 'rewrite_rules_array', onFilterRewriteRulesArray ); 
add_action( 'wp_loaded', onLoadedWP );
function onLoadedWP()
    //Must be done once after rules change
    global $wp_rewrite;

 function onFilterRewriteRulesArray( $rules )
        $newrules = array();
        $newrules['([^/]+)$'] = 'index.php?brandbook=$matches[1]';
        return $newrules + $rules;

Instead of brandbook put your custom post type name/slug.

You can modify regex to your needs as well.

With this code page opens without redirect to custom post type with both of these links:

  • 2
    does this not break the native page post type? also, in this example you're flushing rewrite rules on every request, which is a very bad thing.
    – Milo
    Feb 26, 2013 at 15:54
  • Good point. As it says in comment "Must be done once after rules change", you could make logic to run it once :) yes, it would override page type, but for example you could use 404 action/template to redirect to desired page if custom post type does not exist. Mar 5, 2013 at 14:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.