Pregunta

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');
¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top