Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using this code to get a list of child pages excluding the current page and is working fine.

But... When I'm viewing a child page, the parent page is not listed...

How can I exclude the current page making sure that the parent page get's listed on child pages?

<div style="background-color:#0C1D19">
<?php global $id;
$pages = get_pages(array('child_of' => 7171, 'sort_column' => 'post_date' , 'showposts' => '5' , 'sort_order' => 'desc' ,'exclude'=> $id)); ?> 
<?php foreach ($pages as $page): ?>
<h2><a href="<?php echo get_page_link($page->ID); ?>"><?php echo $page->post_title; ?> </a></h2>
<div style="float:left">
<a href="<?php echo get_page_link($page->ID); ?>" title="<?php echo $page->post_title; ?>"rel="bookmark">
<?php if(has_post_thumbnail($page->ID)) { ?>
<?php echo get_the_post_thumbnail($page->ID, 'mini-thumbnail');?>
<?php } else { ?>
<?php echo '<img src="'.get_bloginfo('template_directory').'/images/pic_post-mini.jpg"/>';?> <?php } ?></a>
<span class="overlay_pages"></span></a>
</div>
<?php wpe_excerpt('wpe_excerptlength_index', 'wpe_excerptmore'); ?>
<?php endforeach; ?> 
</div>
share|improve this question
"How can I exclude the current page making sure that the parent page get's listed on child pages?" What? You want to show the parent page as well as the children? Is that what you mean? – s_ha_dum Mar 19 at 13:54
I want to show parent page on child pages only. If I'm on parent page, I need to exclude it. But if I'm on a child page, I need to list the child pages and the parent page excluding the current page – Alex Mar 19 at 13:57

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.