Come capire se sono su una sottopagina subpage.
Funzione is_subpage()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
function is_subpage() { global $post; // load details about this page if ( is_page() && $post->post_parent ) { // test to see if the page has a parent return $post->post_parent; // return the ID of the parent post #echo "SI SOTTOPAGINA"; #return true; } else { // there is no parent so ... return false; // ... the answer to the question is false #echo "NO SOTTOPAGINA"; } } # DEBUG print_r (is_subpage()); |
esempio:
1 |
if( is_page( array( 'prodotti', 'contatti' ) ) || is_subpage()==29 /*id pagine genitore*/ ){ … }else{...} |
fonte: codex wp reference