• Hello
    i’m trying to make the rewrite of custom post type “news” in custom taxonomy “blog” like this :

    site.com/news/term-title/post-title

    tried this function:

    function filter_post_type_link($link, $post)
    {
        if ($post->post_type != 'news')
            return $link;
    
        if ($cats = get_the_terms($post->ID, 'blog'))
            $link = str_replace('%terms%', array_pop($cats)->slug, $link);
        return $link;
    }
    add_filter('post_type_link', 'filter_post_type_link', 10, 2);

    it make the structure like this :
    site.com/term-title/post-title
    without the slug and also not found 404 for post and term pages!

    Any help, or a quick tut on how to display the desired structure and make it work would be helpful.

    Thanks

  • The topic ‘custom taxonomy in custom post link’ is closed to new replies.