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
.
- What have you already tried? – Max Yudin Commented Mar 1, 2017 at 9:05
1 Answer
Reset to default 1We 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