Getting general posts in custom post archive
-
Hi Team,
I had a thread to display my custom post archive in author and month archive ateI got the below code and its working fine except a bug that when I am clicking on custom post archive, I am getting my general posts below custom posts.
Please help on this.
add_action( 'pre_get_posts', 'include_cpt_in_archives', 100); function include_cpt_in_archives( $query ){ if ( is_admin() || ! $query->is_main_query() || ! ( $query->is_search || $query->is_archive ) ) return; $post_types = get_post_types( array('public'=> true, 'exclude_from_search'=> false, '_builtin' => false) ); // add normal post $post_types['post'] = 'post'; $query -> set('post_type', $post_types); }
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Getting general posts in custom post archive’ is closed to new replies.