The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

problem with query_vars (5 posts)

  1. glennwelker
    Posted 6 years ago #

    I seem to be having a problem with query vars and 3.0. In the past, I used a few filters to add a custom query variable. Now, the custom rewrite rule is confirmed to be there, but WordPress redirects straight back to the category in this case.

    path category/products
    adding query variable product giving me
    path category/products/product/someproduct

    Code used:

    function leprechaun_query($vars) {
            $vars[] = 'product';
            return $vars;
        function leprechaun_flush_rewrite() {
                    global $wp_rewrite;
        function leprechaun_add_rewrite_rules($rules) {
            $new_rules = array();
            $new_rules['category/products/(.+?)/page/?([0-9]{1,})/?$'] = 'index.php?category_name=products&product=$matches[1]&paged=$matches[2]';
            $new_rules['category/products/(.+?)/?$'] = 'index.php?category_name=products&product=$matches[1]';
            return $new_rules + $rules;

    Any ideas what is happening. This code worked previously on two web sites, both seem to be suffering from same problem.

  2. glennwelker
    Posted 6 years ago #

    A little followup. The code can be made to work in a sense.

    if I type something like
    http://www.website.com/content/category/products/?product=website (works)

    what I want is
    the above doesn't work, it just redirects back to .../products

    Like I said, my code worked in the past. Am I doing something wrong?

  3. glennwelker
    Posted 6 years ago #

    Anyone? This is a confirmed bug.

    I downgraded back to 2.9.2 and everything works perfectly. I assume that the changes with custom taxonomies has opened up a whole with previous methods of rewrite rules.

    If anyone can find a work around, I would love to hear about it. I am going to have to stay at 2.9.2 until I can migrate to the new taxonomies. WAY too much time to do it now.

  4. Austin Matzko
    Posted 6 years ago #

    What we can't see from your code is where and when you're attaching the callbacks.

    When do you add the leprechaun_add_rewrite_rules callback? How is leprechaun_query used?

  5. brainspiral
    Posted 6 years ago #

    I'm having the exact same problem, too.

    Our custom rewrite rules and variables brought over from 2.9.2 do not work in 3.0. We were using the BWB Rewriter plugin - which basically just includes the callbacks for the rewrite filters, and they absolutely do not work in 3.0. I guess we'll go back to 2.9.2 as well.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.