Viewing 15 replies - 1 through 15 (of 17 total)
  • <?php
    $gen1 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 0  AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen1_ids = implode($gen1,', ');
    $gen2 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen1_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen1and2_ids=array_merge($gen1,$gen2);
    $ids = implode($gen1and2_ids,', ');
    	$pages = get_pages('include='.$ids);
    	$count = 0;
    	foreach($pages as $page)
    	{
    		//$content = $page->post_content;
    		//if(!$content)
    		//	continue;
    		//if($count >= 2)
    		//	break;
    		//$count++;
    		//$content = apply_filters('the_content', $content);
    	?>
    		<h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
    		<div class="entry"><?php //echo $content ?></div>
    	<?php
    	}
    ?>
    Thread Starter nadine00

    (@nadine00)

    Hmm. That’s showing all the subpages.

    If I change this posts.post_parent = 0 to this posts.post_parent = 9 it just puts me back at the same spot: Lists all the children of page 9.

    I need to limit the sub pages so it only shows the first level of children, not the second level of children.

    Thread Starter nadine00

    (@nadine00)

    Still tinkering with this. Any ideas? Sorry for the questions. :-/

    thanks.

    So if you have:

    Page
    -Page child
    –Page grandchild
    —Page great grandchild
    Page 2
    Page 3
    -Page 3 child
    –Page 3 grandchild

    You want to see only:
    Page
    -Page child
    Page 2
    Page 3
    -Page 3 child

    Correct?

    Thread Starter nadine00

    (@nadine00)

    Close….

    If I have:

    Page
    -Page child
    –Page grandchild
    —Page great grandchild

    I only want to display:

    -Page child

    Its a landing page. So, the landing page is the Parent page, and everything displayed is going to have always have the same parent.

    Nadine.

    <?php
    $gen1 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent = 0  AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen1_ids = implode($gen1,', ');
    $gen2 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen1_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen2_ids = implode($gen2,', ');
    //don't really need these next two lines but left there for example
    $gen3 = $wpdb->get_col("SELECT ID FROM $wpdb->posts WHERE $wpdb->posts.post_parent IN ($gen2_ids) AND $wpdb->posts.post_type = 'page' AND $wpdb->posts.post_status = 'publish' ORDER BY $wpdb->posts.ID ASC");
    $gen3_ids = implode($gen3,', ');
    wp_list_pages('include=' . $gen2_ids . '&title_li=<h2>' . __('Level 2 Pages') . '</h2>');
    ?>
    Thread Starter nadine00

    (@nadine00)

    That’s giving me only:

    –Page grandchild

    One level too far down.

    Link to see the pages you are talking about please.

    Thread Starter nadine00

    (@nadine00)

    http://work.nadinelessio.com/firstsecond/build/book-guides/

    The older code is in there, and I only have the titles in for testing. The FAQ Pages are sub pages of the Volume 1 and Volume 2.

    Trying to find a way so only Volume 1, and Volume 2 info shows up, but none of their children.

    Over in your sidebar, please put the Pages widget or if not using widgets, put this in your sidebar.php

    <?php
    wp_list_pages('title_li=All pages');
    ?>

    Thread Starter nadine00

    (@nadine00)

    Ok. Done.

    So you are wanting this–when visiting the Book Guides page, only want to see:
    o Drawing Words & Writing Pictures Volume 1
    o Drawing Words & Writing Pictures Volume 2

    Thread Starter nadine00

    (@nadine00)

    Yep. That’s it. šŸ™‚

    <?php
    $page_id = $posts[0]->ID;
    $args=array(
      'post_parent' => $page_id,
      'post_type' => 'page',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
        <?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    Thread Starter nadine00

    (@nadine00)

    Thank you!

    Can you explain what you’ve done? I’ve never used caller_get_posts before. Also will wordpress 3.0 have simpler depth handling for get_pages() ?

    Thanks again for your help. That really had me stumped for a long time.

    cheers

    Nadine.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘Restricting child pages’ is closed to new replies.