admin管理员组文章数量:1426895
I have a scenario where i need to make a rewrite rule dynamic so that when permalink is changed the re-write rule should get updated as well
function rewrite_rule() {
global $wp_rewrite;
$post = get_post($result_id);
$post_slug = $post_id ->post_name
add_rewrite_rule('^'.$post_slug.'/([^/]*)/?','index.php?post_type=page&page_id=1234&term=$matches[1]','top');
$wp_rewrite->flush_rules(true);
}
add_action('init', 'rewrite_rule' );
In this case
$post_slug
should be the permalink slug value from wordpress and everytime user changes the permalink value the rewrite should be updated with the value as well
本文标签: pluginsChange custom rewrite rule when permalink is updatedchanged
版权声明:本文标题:plugins - Change custom rewrite rule when permalink is updatedchanged 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745488769a2660506.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论