Need help with add_rewrite_rule
-
My current link is this:
https://www.norwegianfashion.no/designers/?designer=Batlak-og-Selvig&bid=9What I want is this
https://www.norwegianfashion.no/designers/Batlak-og-Selvig/I’m trying to use add_rewrite_rule() to achieve this.
I found this site that wxplains it pretty good: https://www.prodeveloper.org/create-your-own-rewrite-rules-in-wordpress.htmlBut it’s not working ??
function add_rewrite_rules( $wp_rewrite ) { $new_rules = array( '('.$template_page_name.')/designers/(.*?)/?([0-9]{1,})/?$' => 'designers.php?designer='. $wp_rewrite->preg_index(1).'&bid='. $wp_rewrite->preg_index(2) ); // Always add your rules to the top, to make sure your rules have priority $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_action('generate_rewrite_rules', 'add_rewrite_rules'); function query_vars($public_query_vars) { $public_query_vars[] = "designer"; $public_query_vars[] = "bid"; return $public_query_vars; } add_filter('query_vars', 'query_vars')
What am I doing wrong?
Viewing 7 replies - 1 through 7 (of 7 total)
Viewing 7 replies - 1 through 7 (of 7 total)
- The topic ‘Need help with add_rewrite_rule’ is closed to new replies.