• I am pulling child pages and excerpts in certain page templates, but need to exclude a couple of the child from these pages. My basic code that pulls in the child pages/ecerpts works fine, but I am completely stuck as to how to exclude certain pages from showing up.

    Code I hav:

    <?php $pageChildren = $wpdb->get_results("SELECT *    FROM $wpdb->posts WHERE post_parent = ".$post->ID."  AND post_type='page' ORDER BY menu_order", 'OBJECT' ); ?>
    
    <?php if ( $pageChildren ) : foreach ( $pageChildren as $pageChild ) : setup_postdata( $pageChild ); ?> 
    
    <div class="entry">
    
        <h3><a href="<? echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="Permanent Link to <?php echo $pageChild->post_title; ?>"><? echo $pageChild->post_title; ?></a></h3>
    
    <div class="divider"></div>
    	<a href="<?php echo get_page_link($pageChild->ID) ?>">
    <?php echo get_the_post_thumbnail($pageChild->ID, array(), array('class' => 'alignleft')); ?></a><? echo $pageChild->post_excerpt; ?><br />
    
        <div class="more2">
    	<strong><a href="<?php echo get_permalink($pageChild->ID); ?>" rel="bookmark" title="Permanent Link to <?php echo $pageChild->post_title; ?>">Learn More ></a></strong>  </div>
                </div><br />
    
                <?php endforeach; endif; ?>

  • The topic ‘How do you exclude certain child pages from a wpdb custom query?’ is closed to new replies.