website - how to exclude parent pages from get_pages loop Wordpress -


i want display pages in 1 page design.

now have code that:

<?php          $pages = get_pages($args);         //start loop         foreach ($pages $page_data) {             $content = apply_filters('the_content', $page_data->post_content);             $title = $page_data->post_title;             $slug = $page_data->post_name;         ?>         <!-- content section -->         <div class="section" id="<?php echo "$slug" ?>">             <a name="<?php echo "$slug" ?>"></a>             <h2><?php echo "$title" ?></h2>             <?php echo "$content" ?>          </div>         <!-- end content section -->         <?php } ?> 

but show's empty parent pages. how can exclude them? found on website:

if($page->post_parent != 2){ 

but when insert code see home section.

is there way apply different templates different pages? know how done 1 page website difficult.

thnx

i'm guessing "empty pages" mean don't have content inside them.

try check if $content has inside of it, if not, don't display page.

put inside foreach statement right after $slug = $page_data->post_name; , before ?>

if($content == ""){  continue; } 

Comments