質問

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