Dante theme x custom post tags

By May 30, 2016 Wordpress

Dante theme gives you the ability to add tags to your posts but… surprisingly it won’t show up with you try to see the posts associated with that custom post type.

I looked online and found this thread and there’s a simple code that you have to add to your functions.php:

function wpse28145_add_custom_types( $query ) {
    if( is_tag() && $query->is_main_query() ) {

        // this gets all post types:
        $post_types = get_post_types();

        // alternately, you can add just specific post types using this line instead of the above:
        // $post_types = array( 'post', 'your_custom_type' );

        $query->set( 'post_type', $post_types );
    }
}
add_filter( 'pre_get_posts', 'wpse28145_add_custom_types' );

Leave a Reply