Skip to content

Instantly share code, notes, and snippets.

@CEscorcio
Created October 4, 2013 12:48
Show Gist options
  • Save CEscorcio/6825403 to your computer and use it in GitHub Desktop.
Save CEscorcio/6825403 to your computer and use it in GitHub Desktop.
Imprimir menu pai da pagina
<?php if ($post->post_parent) {
$ancestors=get_post_ancestors($post->ID);
$root=count($ancestors)-1;
$parent = $ancestors[$root];
} else {
$parent = $post->ID;
}
$children = wp_list_pages("title_li=&child_of=". $parent ."&echo=0");
// if there are children, this is the resulting content output
if ($children) { ?>
<div class="clear">
<div id="content_left">
<?php the_content('<p>Read the rest of this page &raquo;</p>'); ?>
</div>
<div id="sidebar">
<h4>See also</h4>
<ul id="nav_children">
<?php echo $children; ?>
</ul>
</div>
</div>
<?php } else {
the_content('<p>Read the rest of this page &raquo;</p>'); // if no children, display content normally
} ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment