Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have 2 custom taxonomies that I can query this way:

site.com/?pa_tax1=term&pa_tax2=term2

pa_tax1 and pa_tax2 are custom taxonomies. I want to be able to use something like:

site.com/tax1/tax2 to get the same results. I've been trying to get it done using some of the code provided on theses cases:

Rewrite Rules for Multiple (more than 2) Taxonomies

URL rewrite rules for multiple taxonomies query

None os them is working for me. Any ideas?

Thank you

share|improve this question
Explain why it doesn't work and what happens instead. Add debug information to your question to make answers possible. Show some research efforts. – toscho Sep 25 '12 at 16:07

closed as too localized by toscho Sep 30 '12 at 19:53

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, see the FAQ.

1 Answer

Sorry, I'm new to the site. Won't happen again.

After a little digging, I still no knowing what's wrong. I'm trying this piece of code on my functions.php:

    function custom_rewrite( $wp_rewrite ) {

    $feed_rules = array(
        'product-category/(.+)/material/(.+)/color/(.+)'    =>  'index.php?product_cat='. $wp_rewrite->preg_index(1).'&pa_material='. $wp_rewrite->preg_index(2).'&pa_color='. $wp_rewrite->preg_index(3)
        'product-category/(.+)/color/(.+)'    =>  'index.php?product_cat='. $wp_rewrite->preg_index(1).'&pa_color='. $wp_rewrite->preg_index(2)
        'product-category/(.+)/material/(.+)'    =>  'index.php?product_cat='. $wp_rewrite->preg_index(1).'&pa_material='. $wp_rewrite->preg_index(2)
    );

    $wp_rewrite->rules = $feed_rules + $wp_rewrite->rules;
}
// refresh/flush permalinks in the dashboard if this is changed in any way
add_filter( 'generate_rewrite_rules', 'custom_rewrite' );

Stil, my site won't load. This is what I get from debugging:

Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ')' in /home/marubdaz/public_html/www.site.com/wp-content/themes/builder/functions.php on line 6

Line 6 (part of the array):

'product-category/(.+)/color/(.+)'    =>  'index.php?product_cat='. $wp_rewrite->preg_index(1).'&pa_color='. $wp_rewrite->preg_index(2)

Any ideas? Thank you

---EDIT--- Problem solved. There were a couple of commas missing at the end of the array values :-/

Thanks

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.