Support » Developing with WordPress » problem with pagination and categories, tags and blog

  • I have changed my category and tag base to my list of post called “blog” using the wp build-in permalink settings. For example, the news category looks like myurl.com/blog/news/.

    I’m using wp pagination for both categories and tag, so myurl.com/blog/news/page/2 shows me the second page of the list of posts having the category “news”.

    The page myurl.com/blog works fine and show the list of all posts but if I try to use pagination for my blog (ex: myurl.com/blog/page/2), wordpress thinks it’s a category.

    I tried to use a rewrite rule but it doesn’t work :

    add_action('init', 'my_rewrite_rules');
    function my_rewrite_rules()
    {
        add_rewrite_rule(
            'blog/page/?([0-9]{1,})/?$',
            'index.php?pagename=blog&paged=$matches[1]',
            'top'
        );
    }

    Is there a way to tell wordpress to not consider “page” as a category when I when to display all posts ?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Moderator bcworkz

    (@bcworkz)

    Works for me when tested on my site with permastruct set as /%postname%/%category%/.

    Did you visit the permalinks settings screen after adding your code? (to cause all rewrite rules to be regenerated)

    The ‘top’ parameter should cause that regexp to match the request before encountering any of the WP rewrite rules that involve taxonomy terms.

    Thread Starter akinorikul

    (@akinorikul)

    Hi Bcworks,

    You are right, it works (even with keeping my permastructur to /%postname%/)! I don’t really understand why it wasn’t the case before, I did visit the permalinks screen to refresh the rules…

    May I ask why do you choose to change the permastructure to /%postname%/%category%/ ?

    Moderator bcworkz

    (@bcworkz)

    I just did it to test /blog/news/ type requests. It’s normally just /%postname%/. In any case, it’s on a local test site and changing permastructs wouldn’t effect other users or SEO.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.