Support » Plugins » problem with query_vars

  • 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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • A little followup. The code can be made to work in a sense.

    if I type something like (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?

    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.

    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?

    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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘problem with query_vars’ is closed to new replies.