1

I've 5 custom taxonomies in my WP theme, and I build rewrite rules correctly, but, when I put all taxonomies in the URL i noticed that WP core Works with "OR" filter instead "AND". I need "AND" relation

The url structure is like this:

www.domain.com/tax1/value/tax2/value/tax3/value/tax4/value/tax5/value

Can I change this relation?

I'm working with index.php template

1
  • Have you written any custom function for taxonomy filter ? And please share your .htaccess or your rewrite_rule file.
    – CodeMascot
    Commented Aug 30, 2016 at 15:41

1 Answer 1

0

@the_dramatist My functions.php file contains:

function core_rewrite_rules() {

    global $wp_rewrite;

    $new_rules = array(

'tax1/(.+?)/tax2/(.+?)/tax3/(.+?)/tax4/(.+?)/tax5/(.+?)/?$' => 'index.php?post_type=my-custom-post-type&tax1=' . $wp_rewrite->preg_index(1) . '&tax2=' . $wp_rewrite->preg_index(2) . '&tax3=' . $wp_rewrite->preg_index(3) . '&tax4=' . $wp_rewrite->preg_index(4) . '&tax5=' . $wp_rewrite->preg_index(4),

    );
    $wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action( 'generate_rewrite_rules', 'core_rewrite_rules' );

My autogenerated htaccess:

# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>

# END WordPress

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.