Skip to content

Instantly share code, notes, and snippets.

@hsquareweb
Created June 15, 2012 22:03
Show Gist options
  • Save hsquareweb/2938923 to your computer and use it in GitHub Desktop.
Save hsquareweb/2938923 to your computer and use it in GitHub Desktop.
WP: The Parent Slug
// 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