最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

tags - How to add prefix or suffix to post_tag slug?

programmeradmin0浏览0评论

I want to add prefix or suffix to all post_tag slugs.

For example one tag URL: example/tag/post-tag-slug all such URLs should be suffixed with a suffix: example/tag/post-tag-slug-suffix.

I want to add prefix or suffix to all post_tag slugs.

For example one tag URL: example/tag/post-tag-slug all such URLs should be suffixed with a suffix: example/tag/post-tag-slug-suffix.

Share Improve this question edited Mar 1, 2017 at 9:05 Max Yudin 6,3782 gold badges26 silver badges36 bronze badges asked Mar 1, 2017 at 5:16 user109567user109567 112 bronze badges 1
  • What have you already tried? – Max Yudin Commented Mar 1, 2017 at 9:05
Add a comment  | 

1 Answer 1

Reset to default 1

We can do this by following code:

function custom_tag_rewrite()
{
 add_rewrite_rule("^tag/(.+)-suffix/?$", 'index.php?post_type=post&tag=$matches[1]', 'top');
 flush_rewrite_rules();
}
add_action('init', 'custom_tag_rewrite');

and try open like this http://example/tag/post-tag-slug-suffix

发布评论

评论列表(0)

  1. 暂无评论