Support » Plugins » Get Parent Post (around Attachment)

  • 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);
    echo $parent_title;

    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?

Viewing 1 replies (of 1 total)
  • 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' ); 
    endwhile ?>
    <?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?

Viewing 1 replies (of 1 total)
  • The topic ‘Get Parent Post (around Attachment)’ is closed to new replies.