Now and then little snippets are pretty useful. For a fix in a Premium-Theme, I needed a kind of evaluation, where I am in the site structure and with little effort I was able to expand the classes and react with CSS.
The following code shows the basic for it and
get_pages() is the key from the core of WordPress to get to these results. This function provides the necessary result of using the parameter and the output via the parameter
sort_order provides the sequence and identification of the first page, which is then either the first or last page in this structure.
// First post in structure // simple, but usefull ;) global $post; $page_childs = get_pages( 'child_of=' . $post->post_parent . '&sort_order=ASC' ); $first_child = $page_childs; if ( get_the_ID() === (int) $first_child->ID ) echo 'First Child';
// Last post in structure global $post; $page_childs = get_pages( 'child_of=' . $post->post_parent . '&sort_order=DESC' ); $last_child = $page_childs; if ( get_the_ID() === (int) $last_child->ID ) echo 'Last Child';