Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Last active December 11, 2015 14:39
Show Gist options
  • Save claudiosanches/4615859 to your computer and use it in GitHub Desktop.
Save claudiosanches/4615859 to your computer and use it in GitHub Desktop.
Listar paginas irmãs.
<?php
if ( $post->post_parent ) {
$args = array(
'hierarchical' => 1,
'exclude' => $post->ID,
'child_of' => $post->post_parent,
'post_type' => 'page',
'post_status' => 'publish'
);
} else {
$args = array(
'hierarchical' => 1,
'exclude' => $post->ID,
'child_of' => $post->ID,
'post_type' => 'page',
'post_status' => 'publish'
);
}
$my_pages = get_pages( $args );
echo '<ul>';
foreach ( $my_pages as $my_page ) {
echo sprintf( '<li><a href="%1$s" title="%2$s">%2$s</a></li>', get_permalink( $my_page->ID ), $my_page->post_title );
}
echo '</ul>';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment