Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Custom Post Types don’t show up in Tag Archive Page

  • Hi,
    im running generatepress pro and generateblock pro with the info theme.

    I created a custom post type and filled it with 100 posts. All posts have a tag that the regular posts also have. The custom post types are not showing on the tag archive page, only the regular posts with that tag.

    Is there anything i have to change on the theme?

    Thanks

  • Hi there,

    you need to tell WordPress to include the CPT in the tag Archives.
    A simple option is to use the pre_get_posts hook. Here is some PHP to do that:

    
    function include_custom_post_type_in_tag_archive($query) {
        if (is_admin() || !$query->is_main_query() || !$query->is_tag())
            return;
        $query->set('post_type', array('post', 'custom_post_type'));
    }
    add_action('pre_get_posts', 'include_custom_post_type_in_tag_archive');
    

    In the code, change the custom_post_type slug for your CPT.

    Adding PHP:
    https://docs.generatepress.com/article/adding-php/

  • Ah thanks! Works like a charm. For anyone else interested: the slug is “Post Type Key *” in ACF.

  • Glad to hear that

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.