Created
May 25, 2021 10:44
-
-
Save DanCanetti/0871d2df7052b78dd9af2a7278ae6828 to your computer and use it in GitHub Desktop.
WordPress is_child by slug (add to functions.php)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Is child | |
function is_child($post_slug) { | |
global $post; | |
$parent_id = $post->post_parent; | |
$post_slug = get_post_field( 'post_name', $parent_id ); | |
if( is_page() && ($post_slug) ) { | |
return true; | |
} else { | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment