Check if Page has Siblings

Works great if you’re using a sub-menu that shows related-level items when on a page.

function has_sibling() {
global $post;
if ( $post->post_parent ) {
$siblings = get_pages( 'child_of='.$post->post_parent );
if ( count($siblings) > 1 ) {
return true;
} else {
return false;
}
} else {
return false;
}
}

Source.

Leave a Reply

Posted in php
katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.