Link Featured Thumb to Attachment Page, If Possible

Are featured thumbs uploaded the same as other images and have their own attachment post url?

I’m trying to utilize the 3.0+ post formats and am using the featured image when creating a post under the ‘image’ post format. I would like to link the image from the blog loop to its attachment page, which I have already customized for my gallery post format images.

Read More

Looking for the right direction. One thing I noticed is that custom post types can have their own page templates e.g.:

single-post_type.php

but post formats do not?

So my questions: 1. – how do you link a featured image from the blog home page to its attachement page (or what is the best solution if it does not have one)? 2. – is there a way to create custom ‘single’ pages for post formats (or do I use conditionals on single.php)?

Thanks.

Related posts

Leave a Reply

1 comment

  1. Question 1: How do you link Featured Image to its Attachment Page

    In the loop:

    <?php if( has_post_thumbnail() ) : ?>
    <a href="<?php echo get_attachment_link( get_post_thumbnail_id() ); ?>">
        <?php the_post_thumbnail(); ?>
    </a>
    <?php endif; ?>
    

    Question 2: Post Format Templating

    Post formats are actually just a custom taxonomy with a fancy UI. Hence, you should be able to access and style the post format archive pages via the template hierarchy (admittedly, I’ve never tried), but you can’t style the individual pages.

    Lucky for us though, Twenty Eleven shows us the way. Line 27 of index.php:

    <?php get_template_part( 'content', get_post_format() ); ?>
    

    get_template_part() is a great function, and you should just read it’s Codex entry. It’s better than me trying to rewrite it as an answer.

    Now, in that loop, you create a file called content.php for a fallback and then add content-video.php, content-link.php, etc. for whichever formats you want to customize.