WordPress.org

Ready to get started?Download WordPress

Forums

post__not_in excluding children as well? how to? (1 post)

  1. exiledesigns
    Member
    Posted 2 years ago #

    Hello,

    I'm trying to display on my homepage a list of the last Posts + a list of the last Pages.
    Below, how my Pages Loop looks like (it basically works).

    My problem is that when I remove Pages, using 'post__not_in', it also removes their children. But what I want if for those children *only* to show.

    Example: I have a Guides category (635), with a few countries in it (675,986,1022,etc.)
    Every country Page has children guides, those are the one I want to show in the loop. I don't want to show the country pages, because they are just indexes, not proper articles.

    Many thanks for your help!

    <?php /*loop for pages*/
      	rewind_posts();
    	$parent = $post->ID;
    	$args=array(
      		'post_parent' => '635',/*parent=guides*/
      		'post__not_in' => array(675,986,1022,1041,1070,1594,1713,2138,2467,2478,2486),/*country pages*/
       		'post_type' => 'page',
      		'posts_per_page' => '2',
      		'orderby' => 'date',
      		'order' => 'DESC'
    	);
    	query_posts($args);
    	 while (have_posts()) : the_post();
    	?>

    [ Please do not bump, shamelessly or otherwise. That's not permitted here. ]

Topic Closed

This topic has been closed to new replies.

About this Topic