-
atradior
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 thepre_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/ -
atradior
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.