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

categories - How do you change the permalink for posts for a single category?

programmeradmin0浏览0评论

I have a number of posts using the default post type. Each is assigned to a category and the permalink structure /category/postname. For one specific category I would like to use the permalink structure /someother/category/postname.

So for example category test_a and test_b all remain as standard but any post put in category test_c I would like the URL/permalink to be /someother/test_c/postname

Following what I have done similarly I have:

function my_category_post_link($permalink, $post, $leavename){

   if ($permalink == "/"){
      return "/";
   }
}
add_filter('post_link', 'my_category_post_link',10,3);

This is a highly simplified view and obviously I alter the logic, etc. Anyway I can get that bit to work. The resulting link results in a 404. Previously I would then add a add_rewrite_rule but this doesn't seem to work and to be honest not 100% it is the right thing to do. Can anyone just point me in the right direction?

发布评论

评论列表(0)

  1. 暂无评论