Help to get parent post slug
-
I’m having trouble outputting the parent slug.
Here’s what I’ve got so far (however this currently outputs nothing within the $media_items parameters):
<?php function the_parent_slug() { global $post; if($post->post_parent == 0) return ''; $post_data = get_post($post->post_parent); return $post_data->post_name; } ?> <?php $media_items = get_attachments_by_media_tags('size=thumb&media_tags='.$the_parent_slug); ?>
I’ve also tried putting ‘the_parent_slug’ within an echo to see if anything is output and I get nothing.
<?php echo '' . $the_parent_slug . ''; ?>
Probably something simple?
[Moderator Note: Please post code or markup snippets between backticks or use the code button. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Help to get parent post slug’ is closed to new replies.