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

url rewriting - Add slug to default post permalinks ONLY

programmeradmin1浏览0评论

I've been browsing and reading and testing and can't seem to find a clean solution for my problem. A solution that doesn't affect all other post types, categories, custom taxonomies, etc. :(

Is there anyway to modify the default post permastructure only programmatically by prepending an hardcoded slug to it?

As of now, I've tried using $wp_rewrite, add_permastruct, set_permalink_structure...

Thank you in advance for your help.

I've been browsing and reading and testing and can't seem to find a clean solution for my problem. A solution that doesn't affect all other post types, categories, custom taxonomies, etc. :(

Is there anyway to modify the default post permastructure only programmatically by prepending an hardcoded slug to it?

As of now, I've tried using $wp_rewrite, add_permastruct, set_permalink_structure...

Thank you in advance for your help.

Share Improve this question asked May 17, 2019 at 7:49 user167290user167290 4
  • Try this – nmr Commented May 17, 2019 at 8:08
  • Thanks. Just found a simple answer -> gotta hook the function to post_link. developer.wordpress/reference/hooks/post_link – user167290 Commented May 17, 2019 at 8:09
  • If you only use the post_link filter, you change the links generated by WordPress, but these addresses may not be recognized. – nmr Commented May 17, 2019 at 8:22
  • It works, I had defined new rules previously using add_rewrite_rule. wordpress.stackexchange/questions/337924/… – user167290 Commented May 17, 2019 at 9:06
Add a comment  | 

1 Answer 1

Reset to default 0

Literally found the answer 10 minutes after posting this question and spending a couple of hours on it before asking. Simply hook your function to post_link!

发布评论

评论列表(0)

  1. 暂无评论