Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_filter( 'pre_get_posts', 'my_cptui_add_post_types_to_archives' );
- function my_cptui_add_post_types_to_archives( $query ) {
- // We do not want unintended consequences.
- if ( is_admin() || ! $query->is_main_query() ) {
- return;
- }
- if ( is_category() || is_tag() && empty( $query->query_vars['suppress_filters'] ) ) {
- // REPLACE THESE SLUGS WITH THE POST TYPES YOU WANT TO INCLUDE.
- $cptui_post_types = array( 'custom-post-type');
- $query->set(
- 'post_type',
- array_merge(
- array( 'post' ),
- $cptui_post_types
- )
- );
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement