WP custom post type not working with other post types in custom queryAsk Question


I have really wierd problem, namely I have 3 types of posts: one is default post and other two (custom) are products and advice. The problem is the advice post type is not included in search (I have added custom post types top search query with pre_get_posts filter). Even if I use custom query and pass an argument 'post_type' => array('post, advice, products') the advice is exluded. But whent I query 'post_type' => 'advice' it's working then.

Anybody has any idea what can cause this problem?

Thanks in advance


Use this. It will work

$args = array(
  'post_type' => array( 'post', 'advice', 'products'),
  'post_status' => 'publish',
  'posts_per_page' => -1,
$newsQuery = new WP_Query($args);
if ( $newsQuery->have_posts() ) {
   while ($newsQuery->have_posts()) {
        echo get_the_title();
        echo get_the_excerpt();
© 2014 TuiCode, Inc.