admin管理员组

文章数量:1312662

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

本文标签: tagsHow to add prefix or suffix to posttag slug