سؤال

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');
هل كانت مفيدة؟

المحلول

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top