Pagination on Custom Tax Pages Removes Spaces from Query Vars

I’ve got a weird problem that’s very similar to this one: Why does WordPress Pagination Remove the Spaces from my GET Variable?. Except that mine isn’t withn search results pages–it’s with custom taxonomy pages.

Here’s the problem: clean WP install with no plugins. I add a custom taxonomy like so in my functions file:

Read More
register_taxonomy(
    'my-categories',
    array(
        'post',
    ),
    array(
        'hierarchical' => true,
        'label' => 'My Categories',
        'query_var' => true,
        'rewrite' => array( 'slug' => 'my-categories' ),
    )
);

I’ve created a term in this taxonomy called “test one”. If I go to the taxonomy page and add a custom var to the query string, everything seems fine (like so: /my-categories/test-one/?something=one+two).

Here’s where it gets weird: if I add in some pagination vars (manually changing the URL to /my-categories/test-one/page/2/?something=one+two), the resulting page actually rewrites my URL, stripping out spaces from the custom var (the resulting URL is /my-categories/test-one/page/2/?something=onetwo).

Adding my custom var to the vars list using the query_vars filter has no effect.

There is obviously a bad rewrite happening somewhere in the WordPress core (I assume in the register_taxonomy() function?), but I don’t know enough about WP’s rewriting API to figure out what it is. Anybody have any ideas?

I’ll file an issue in Trac if it is indeed a bug, but I need to know how to patch it short-term.

Related posts

Leave a Reply

1 comment