3

I get with that code some pictures from different pages they have a special parent page.

$query = new WP_Query( 
    array(
        'post_type'       => 'page', 
        'post_parent__in' => array(376, 379), 
        'orderby'         => 'title', 
        'order'           => ASC,  
        'posts_per_page'  => 9999
    )
);

But now i want that the code not only look for parent pages but also for single pages. Is it possible to combine post_parent__in & post__in?

$query = new WP_Query( 
    array(
        'post_type'       => 'page', 
        'post_parent__in' => array(376, 379),
        'post__in'        => array(1148),
        'orderby'         => 'title', 
        'order'           => ASC,  
        'posts_per_page'  => 9999
    )
);

If i use the second code it shows me nothing. It should look for images they are have a parent page or a specific page id.

Thx for your Help

Shortcode code:

function galerie_klassisch_wohnen() { 

$query = new WP_Query( 
    array(
        'post_type'       => 'page', 
        'post_parent__in' => array(376, 379, 382),
        'orderby'         => 'title', 
        'order'           => ASC,  
        'posts_per_page'  => 9999
    )
);
   if ( $query->have_posts() ) : while($query->have_posts()) : $query->the_post();
         $return_string .= '<div class="dynamische-galerie"><div class="col-3"><div class="dynamische-galerie-wrapper"><a href="'.get_permalink().'">'.get_the_post_thumbnail( $post_id, array(285,200) ).'</a><div class="dynamische-galerie-caption"><a href="'.get_permalink().'"><b>'.get_the_title().'</b><br>'.number_format(get_field( 'nettogrundflaeche' ),2,',','.').'<span>&nbsp;m²</span></a></div></div></div></div>';
      endwhile;
      return $return_string;
endif;

wp_reset_postdata(); 
}
add_shortcode( 'galerie_klassisch_wohnen', 'galerie_klassisch_wohnen' );

1 Answer 1

2

NO, you cannot combine post_in and post_not_in in the same query. Both are mutually exclusive, So it is impossible for mutually exclusive events to occur at the same time.

2
  • I use this code inside a shortcode, can i combine perhaps different loops to get this to work. I post the complete code above. Commented Dec 18, 2014 at 11:09
  • -1 It's post_parent__in and post__in, which are not mutually exclusive.
    – bonger
    Commented Dec 18, 2014 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.