Support » Plugin: WP No Category Base » [Plugin: WP No Category Base] How to make pages have priority over category?

  • Hi,

    well I use the plugin a lot in order to use WordPress as a CMS.

    So in the past I did the following.

    – add a category “news” with the slug “news”
    – add a page “news” with the slug “news”

    So as you see the page and the category have the same slug.

    In the past when I went to it would show the page with all the content. And that was exactly how I needed it.

    But after upgrading to wp 3.1 it now shows the category page with the posts listed.
    So it seems, that after upgrading to 3.1 category pages have priority over pages.

    How do I change this back? I am relying havily on pages having priority, if the same slug is used on a category.

    Thank you very much for help.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author iDope


    Unfortunately this is the way WordPress rewrite rules work. I do not make any changes to the order the rules are processed. The rewrite rules for pages are processed last which makes sense as they are essentially “catch-all” (a page link can be Trying to move the rewrite rules up (even if possible) might add a significant performance penalty.

    Thanks for the explenation iDope.

    I wonder why they changed this.

    You said one can move the rewrite rules for the pages up in the process. Can you show me a way of how do do this? I searched all day long for a solution on how to do this, but had no luck.

    Even if it will get me a performance penalty, I really need this. And by using WP-Cache the penalty hopefully would not make that much of a difference.

    Thanks a lot iDope



    I’ve run into the exact same problem. We were using pages in place of the default category listing, but the 3.1 update has broken all of them. If anyone has ideas on how to change the page/category priority it would be a huge help.

    Plugin Author iDope


    Sorry, I don’t have a solution to this as of now.

    All of my sites are running the No Category Base plugin and this issue has been something that has plagued me since upgrading to version 3.1. The following test was done using wordpress 3.1.1.

    By default, worpdress has always placed the “category” priority over “page” priority – even in earlier versions. To test this theory, try creating a page title the same as what you setup your permalink category base to (or set the page title to category if your permalink category base is blank); The page doesn’t auto load UNTIL you activate the No Category Base Plugin.

    I found a simple function script that removes category from the URL structure and still places the “category” priority over “page”.

    add_filter('user_trailingslashit', 'remcat_function');
    function remcat_function($link) {
        return str_replace("/category/", "/", $link);
    add_action('init', 'remcat_flush_rules');
    function remcat_flush_rules() {
        global $wp_rewrite;
    add_filter('generate_rewrite_rules', 'remcat_rewrite');
    function remcat_rewrite($wp_rewrite) {
        $new_rules = array('(.+)/page/(.+)/?' => 'index.php?category_name='.$wp_rewrite->preg_index(1).'&paged='.$wp_rewrite->preg_index(2));
        $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;

    Is it the order by which this script flushes the rewrite and reestablishes the rules that makes it work?

    I did find one flaw in the above script – you get a 404 when looking for sub-categories (ex: If you load the post directly (ex: it will come up, but sub-categories won’t list out.

    Try this

    How to make pages slug have priority over any other taxonomies like custom-post, post or category

    It is working for me and it doesn’t have problems with the sub-categories =)

    How do I change the URL of my post from the default to let’s say

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘[Plugin: WP No Category Base] How to make pages have priority over category?’ is closed to new replies.