Quando hai sottopagine o pagine figlie con un ID genitore in WordPress, potresti voler verificare l'ID della pagina genitore per le tue sottopagine o pagine figlie.
Istruzioni: Aggiungi il seguente codice al file functions.php del tuo tema WordPress per restituire l'ID se la pagina genitore esiste.
function is_subpage() {
global $post;
if ( is_page() && $post->post_parent ) {
return $post->post_parent;
} else {
return false;
}
}
Potrebbe interessarti anche cosa fare e non fare nel theming efficace di WordPress.
Commenti Lascia una risposta