Custom Params in URL

The regex you have in the rewrite rule, ([0-9]+), will not match your query string ex%2021. Try ?b=21 and see if that works. Also, new rewrite rules require that the rewrite rules are flushed. You can do this one of two ways. Either call flush_rewrite_rules(); or go to Settings > Permalinks and click save. Please … Read more

Rewrite query var on postname

So, first up, I don’t believe that you need a rewrite tag in this situation, so you can omit that. The issue, I believe, with the remaining code is that your rewrite rule is only capturing 1 match (because there’s only one set of ()), so subpage isn’t receiving a value. Additionally, your rule seems … Read more

URL rewrite rule

function custom_rewrite_rules() { add_rewrite_rule( ‘^product_brand/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?product_brand=$matches[1]&page=$matches[2]’, ‘top’ ); add_rewrite_rule( ‘^product_brand/([^/]+)/([^/]+)/page/([0-9]{1,})/?’, ‘index.php?product_brand=$matches[1]&product_cat=$matches[2]&page=$matches[3]’, ‘top’ ); add_rewrite_rule(‘^product_brand/([^/]+)/([^/]+)?’, ‘index.php?product_brand=$matches[1]&product_cat=$matches[2]’, ‘top’); add_filter( ‘query_vars’, function( $vars ){ $vars[] = ‘product_brand’; $vars[] = ‘product_cat’; return $vars; } ); } add_action(‘init’, ‘custom_rewrite_rules’); and pagination add_action( ‘pre_get_posts’, function() { $page = get_query_var(‘page’); $query->set( ‘paged’, $page ); return $query; } );

How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug

First, you don’t need to have two actions called during init, they can both be done under the same action function — so move the register CPT and taxonomy to a single function (or call separate functions from the main one) — no need to have two init actions. You should also be registering the … Read more