Created
October 4, 2013 12:48
-
-
Save CEscorcio/6825403 to your computer and use it in GitHub Desktop.
Imprimir menu pai da pagina
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 »</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 »</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