I tried many solutions provided in many thread but can't figure how to get this working ...

I'd like my post to have a full "silo" structure based on the category prefix set on admin panel (Settings>Permalinks).

Assuming I've set "news" as category base I'd like to have the following structure for my posts and categories :

  • website.com/news/

  • website.com/news/category-1

  • website.com/news/category-1/subcategory-1/

  • website.com/news/category-1/subcategory-1/post-title

I tried to use the following code in functions.php :

function set_post_permalinks( $post_link, $post ){
    if ( is_object( $post ) && $post->post_type == 'post' ){
        $prefix = get_option( 'category_base' );
        $post_link = $prefix .'/'. $post_link;
    return $post_link;
add_filter( 'post_type_link', 'set_post_permalinks', 1, 3 );

But this isn't working and my posts still got the following structure :

  • website.com/category-1/subcategory-1/post-title

If any ideas, as the site already exists, is there a way to 301 redirect all

  • website.com/category-1/subcategory-1/post-title


  • website.com/news/category-1/subcategory-1/post-title
  • 1
    Why don't you set the category base in the permalink settings? If it doesn't work that way, there is most likely some plugin interfering with the functionality. – Jack Johansson Sep 15 '17 at 7:42
  • As I said it is already set in permalink settings but the prefix is removed from posts permalink but is present in categories and subcategories, I'll investigate – Amandine Sep 15 '17 at 7:53
  • Have you also tried using post_link or the_permalink filters? – Jack Johansson Sep 15 '17 at 8:06
  • I can add my prefix using post_link but this results in a 404. Thanks for your help – Amandine Sep 15 '17 at 8:24
  • I just tested seeting up the post permalink to /news/%category%/%postname%/ and it just works. – cybmeta Sep 15 '17 at 9:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.