Rewrite rule not working, issue may be in URI request

I think you should do something like this: function my_rewrite_rule() { add_rewrite_rule(‘^prefix/section/([0-9]+)/([^/]*)?’, ‘index.php?section=$matches[1]&name=$matches[2]&post_type=post’, ‘top’); } add_action(‘init’, ‘my_rewrite_rule’); Add a query var for section: function my_query_vars( $vars ) { $vars[] = ‘section’; return $vars; } add_action( ‘query_vars’, ‘my_query_vars’ ); I created the pattern for your section (which can be 1 or 2) and used $matches[2] to … Read more

Custom permalink question

What you need is to register your own Rewrite Rule. To do it you should use add_rewrite_rule function. function my_custom_external_rewrite_rule() { add_rewrite_rule(‘^post-type-name/([^/]+)/?’, ‘index.php?page_id=<PAGE_ID>&external_page_name=$matches[1]’, ‘top’); } add_action( ‘init’, ‘my_custom_external_rewrite_rule’ ); And you’ll have to register your custom query variable (using query_vars hook): function my_custom_external_query_var( $query_vars ) { $query_vars[] = ‘external_page_name’; return $query_vars; } add_filter( ‘query_vars’, ‘my_custom_external_query_var’ … Read more

WordPress add_rewrite_rule with 2 variables

After lots of pulling my hair out I figured out the problem. I needed to use the add_rewrite_tag() function to tell wordpress to allow my query vars. function prefix_movie_rewrite_rule() { add_rewrite_tag(‘%state_id%’, ‘([A-Za-z0-9\-\_]+)’); add_rewrite_tag(‘%state%’, ‘([A-Za-z0-9\-\_]+)’); add_rewrite_rule ( ‘states/([A-Za-z0-9\-\_]+)/([A-Za-z0-9\-\_]+)’, ‘index.php? state_id=$matches[1]&state=$matches[2]’, ‘top’ ); } add_action( ‘init’, ‘prefix_movie_rewrite_rule’);

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

add_rewrite_rule wordpress ignoring url pattern, wp rewrite not working

You are trying to match 7-number-cities-starting-with-pa URL to ^([^/]*)-letter-words-starting-with- pattern in second rule. These rules should work: add_action( ‘init’ , ‘se336474_rewrite_rules’, 5 ); add_filter( ‘query_vars’, ‘se336474_query_vars’ ); function se336474_rewrite_rules() { // single pattern for URLs: // site.com/cities-starting-with-pa/ => start_letter=”pa” // site.com/7-cities-starting-with-pi/ => start_letter=”pi”, length=7 add_rewrite_rule( ‘^(?:([0-9]+)-)?cities-starting-with-([^/]*)/?$’, ‘index.php?page_id=340&start_letter=$matches[2]&length=$matches[1]’, ‘top’ ); // // OR for URLs: // … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)