Support » Plugins and Hacks » Get Parent Post (around Attachment)
4 years, 2 months ago
Well first, i hope i’m right here. My question is mostly simple, but i cant release what i want to build, so i hope i get a small help here.
i’m rebuilding my own theme and want modify the attachment.php / image.php page.
what i want to build is, that these pages will show the Parent Post on the attachment page too. i know i can get the information like parent Post title on an easy way:
$parent_title = get_the_title($post->post_parent);
i thought it would be easier to build in the loop from the single.php file, which loads the content style from a own php templage file.
<?php while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
do you know an answer? or is there a more easier way?
well mostly founded something which goes in my direction..
<?php $recent = new WP_Query();
if($recent->have_posts()) : while($recent->have_posts()): $recent->the_post();
get_template_part( 'content', 'index' );
<?php else : ?>
<p> Nothing to see here. Move along </p>
<?php endif ?>
showing up the last 5 posts in general, how can i modify this in the parent post?