Support » Theme: Twenty Twelve » Featured Image link to post

Viewing 13 replies - 1 through 13 (of 13 total)
  • Are you using a child theme?

    Yes.

    And is this just for the Featured post in your child theme’s copy of content.php?

    I’m sorry, I don’t understand the question.

    You can see what I’m doing here: http://www.thebirdbrowser.com/

    Some posts include a ‘Featured Image’. These show up on the home page, and also category archive and search results.

    I’d like these images to have the same link as title.

    (There may be an added complication in that I’m using a plugin (‘Page Links To’) to point post titles to external links…)

    Any thoughts?

    The only post that shows a featured image on the main posts page is the Featured post (usually the first post).

    I’m afraid I don’t understand you again. Perhaps I’m confusing things by using the wrong words…

    On the site I’ve created – http://www.thebirdbrowser.com/ – the ‘Home’ page displays multiple posts, including and image, which has been inserted using the ‘Featured Image’ panel in ‘Add New Post’.

    I’d like those images to have the same link as the post title.

    I’ve experimented with other themes, for example Reddle, and the images had the same link, so I’m hoping this should be possible…?

    Thanks for your patience.

    R

    The only post that shows a featured image on the main posts page in the original Twenty Twelve theme is the the first post.

    Well, I appreciate your trying to help, but I don’t think what you say can be correct…

    The ‘Home’ section (is this the ‘main posts page’) on the link that I’ve given shows multiple images right?

    All of them were added using the ‘Featured Image’ panel.

    This was the same with the default Twelve Theme, and the only things I’ve done with the child theme are minor styling changes.

    Bush

    (@manishkumarruhil)

    Hey you can do this by editing your theme’s (twenty twelve) content.php (create child theme its very important).

    Note that I am not very good at php. So do it at your own risk.

    find this in content.php:

    <?php the_post_thumbnail(); ?>

    remove it. Than find this code:

    <a>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>

    And change it to:

    <a>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?><?php the_title(); ?></a>

    You can see here that it have added:
    <?php the_post_thumbnail(); ?

    before:
    <?php the_title(); ?>

    in <a href="permalink"> </a>

    If it don’t work for you or you are having issues than please notify us.

    [Please post code & markup between backticks or use the code button. Your posted code HAS been permanently damaged by the forum’s parser.]

    Thanks,

    Actually I did a bit of digging around and found this on the codex – to be added to a child ‘functions.php’ file… Seems to do the trick.

    add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 );
    
    function my_post_image_html( $html, $post_id, $post_image_id ) {
    
      $html = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_post_field( 'post_title', $post_id ) ) . '">' . $html . '</a>';
      return $html;
    
    }

    Thanks for all the help!

    Bush

    (@manishkumarruhil)

    Well thats great! you found a safer and the actual way of doing it.

    @bluesinlondon this worked for me… sorta. I used JetPack’s “Related Posts”. While the fix worked to link the featured image to the post, it also created a problem with my JetPack Related Posts plugin. It causes the related post thumbnails (and it’s text links) to go to the dashboard. Didn’t see that one coming. I tried an alternate Related Posts plugin and the problem didn’t carry over. I’m quite fond of the JetPack Related Posts plugin so I’m semi-bummed, it’s a trade-off that I’m just gonna have to deal with until there’s a fix for this issue.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Featured Image link to post’ is closed to new replies.