I've faced a situation with CPT UI and Elementor. I've created a CPT with categories and tags. But, when I tried to create a template for those tags (to dynamically redirect to my CPT posts associated to this tag), it's no showing anything.

After much research, I've found the solution :

add_action( 'pre_get_posts', function ( $q )
    if (  !is_admin() // Only target front end queries
          && $q->is_main_query() // Only target the main query
          && $q->is_tag()        // Only target tag archives
    ) {
        $q->set( 'post_type', ['post', 'custom_post_type'] ); // Change 'custom_post_type' to YOUR Custom Post Type
                                                              // You can add multiple CPT's separated by comma's

Thank you to https://geekonheels.com/tutorial/when-your-custom-post-type-cpt-does-not-show-up-in-your-tag-archive/

I only put it here to help people stuck like me to find this solution.

  • Kevin, there's an option to post your own answer to your question, that way you can flag it as accepted and when people in the future have the same problem they can see that it has been 'Answered' and know that it works. – Tony Djukic Jan 12 at 16:21

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.