Created
June 15, 2012 22:03
-
-
Save hsquareweb/2938923 to your computer and use it in GitHub Desktop.
WP: The Parent Slug
This file contains hidden or 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
// inside functions.php | |
function the_parent_slug() { | |
global $post; | |
if ($post->post_parent == 0 && $post->post_parent) return ''; | |
$post_data = get_post($post->post_parent); | |
return $post_data->post_name; | |
} | |
// initiate anywhere | |
<?php echo the_parent_slug(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment