Breadcrumbs showing Parent and Child Pages

idk about working it back into your breadcrumbs… which by nature i think are hierarchical.

but this should give you a list of the pages that have the same parent as the page you are on (aka its siblings) albeit in a totally unstyled way

global $post;

$args = array('child_of' => $post->post_parent, 'exclude'=> $post->ID);
if ($post->post_parent) $pages = get_pages($args);

if ($pages) foreach ($pages as $page): 
    echo $page->post_title .'<br/>';
endforeach;

if you list your current page and then list off its siblings then you can programmatically recreate what you are looking for i think

edit 1: setup postdata so we can use get_permalink(), get_the_title() inside a “loop” etc instead of object methods. get_permalink() gets the URL to the current item in the loop

global $post;

$args = array('child_of' => $post->post_parent, 'exclude'=> $post->ID);
if ($post->post_parent) $pages = get_pages($args);

if ($pages) :

//store the $temp variable
$temp = $post;

$siblings="<ul>";

foreach ($pages as $post): setup_postdata($post); 

    $siblings .= '<li><a href="'.get_permalink().'">'.get_the_title().'</a></li>';
endforeach;

//restore the $post variable
$post = $temp;

$siblings .= '</ul>';

echo $siblings;

endif;

the args are different, but
http://codex.wordpress.org/Function_Reference/get_posts#Reset_after_Postlists_with_offset
is the foreach loop i usually work off of. it is also got get_posts, but get_pages works the same except that it only returns pages.

Leave a Comment

tech