Domanda

I want to add my own rewrite rule to Wordpress but I cannot get it working. What's wrong?

function rcl_custom_rewrite_rule() { 
      add_rewrite_tag('%post-group%','([^&]+)');
      add_rewrite_rule('^recipe/(.*?)$', 'index.php?post-group=$matches[1]', 'top');
}
add_action('init', 'rcl_custom_rewrite_rule');
È stato utile?

Soluzione

Are you sure that it doesn't work? These rules will not write something to the htaccess file. Have you checked how your rules work manually?

Also make sure that you execute the function flush_rules after adding these rules.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top