Making images link to post

Viewing 15 posts - 1 through 15 (of 17 total)
  • #1971
    trashwire
    Participant

    First off, I LOVE the theme! I’m using it on trashwire.com and it looks great.

    I was just wondering if there’s a way to make the featured image a link to the post so people could click on the image in addition to the headline or “read more” link. Is it possible to drop in some code on the home.php file (or somewhere else) to make the images link to the full post?

    Thanks for such a great theme!

    #1972
    Daniel Tara
    Keymaster

    Sure there is.

    In functions.php, replace the line:

    the_post_thumbnail(array($width,$height), array('alt' => $title));

    with:

    <a" href="<?php the_permalink(); ?>">the_post_thumbnail(array($width,$height), array('alt' => $title));</a">
    #1973
    trashwire
    Participant

    Thanks for such a quick response!

    I tried inserting that code, but it gave me this message:
    Parse error: syntax error, unexpected ‘<‘ infunctions.php on line 219

    I copied and pasted the code from your post, so I think it is correct, but then when I click save changes, it gives me that error.

    Is there something else I should try?

    #1974
    Daniel Tara
    Keymaster

    I think the correct code is this:

    ?><a" href="<?php the_permalink(); ?>">the_post_thumbnail(array($width,$height), array('alt' => $title));</a"><?php

    It also has a typo, remove the ” after the <a

    #1975
    trashwire
    Participant

    Hey Daniel,

    Sorry to keep asking, but it still doesn’t seem to be working. I’m sure I’m probably entering something wrong, but I can’t figure out what.

    I’m talking this:
    [code]
    if ( function_exists( ‘has_post_thumbnail’ ) && has_post_thumbnail() )
    {
    $title = get_the_title();
    the_post_thumbnail(array($width,$height), array(‘alt’ => $title));
    }
    [/code]

    and replacing
    [code]the_post_thumbnail(array($width,$height), array(‘alt’ => $title));[/code]
    with
    [code]?><a” href=”<?php the_permalink(); ?>”>the_post_thumbnail(array($width,$height), array(‘alt’ => $title));</a”><?php
    [/code]

    But it gives me an error message saying [quote]”Parse error: syntax error, unexpected ‘<‘ in /home/trashwir/public_html/wp-content/themes/cover-wp/functions.php on line 219″[/quote]

    I also tried removing the ” after the first <a, but that didn’t work either.

    Can you explain what I’m doing wrong?

    Thanks!

    [b]UPDATE[/b]

    I think I figured it out. It looks like this makes it work.
    [code]
    ?><a” href=”<?php the_permalink(); ?>”><?php the_post_thumbnail(array($width,$height), array(‘alt’ => $title));?><?php[/code]

    #1976
    maurizio04
    Participant

    Could you make it a default feature?

    #1977
    maurizio04
    Participant

    @trashwire
    Could you post the color modification you did on your site, nice work πŸ™‚

    #1978
    trashwire
    Participant

    @maurizio04
    Thanks so much!

    To change the colors, I replaced the images (the png files) with ones that fit my desired color scheme. Then I added the code for those colors into the mystyle.css file. The colors for the sections aren’t controlled by hex codes alone, there are images that have the gradient at the top, so you have to match the code with the color at the bottom of those png files. Does that make any sense?

    #1979
    maurizio04
    Participant

    yes, and making the gradient files is complicated for anyone that do not use frequently Photoshop…..

    #1980
    oro77
    Participant

    Sorry to up an old post but I did not manage to make the link to the post through the feature post image.

    I have changed the functions.php (line 219)

    [code]
    ?><a” href=”<?php the_permalink(); ?>”><?php the_post_thumbnail(array($width,$height), array(‘alt’ => $title));?><?php
    [/code]

    I did not have syntax problem but my feature image is still not linked. Did I misunderstand something ?

    Thank you in advance.

    #1981
    oro77
    Participant
    #1984
    gdaniels99
    Participant

    I’m using version 1.6.6 and have tried every single solution in this thread and none of them solve the problem…the thumbnail image is still not clickable. And some of the solutions crashed my site. So how about just adding this functionality to a future update of the theme?

    #6236
    miz.michele
    Participant

    It drives me crazy when people get answers and won’t share them so hopefully this will help someone. I’ve tried to post the code that works but for some reason it is not posting property so I put it in a paste bin that you can find here http://pastebin.com/sBDpRxfE

    If you replace line 219 with this line, the images will link to your posts.

    • This reply was modified 11 years, 7 months ago by miz.michele.
    #6237
    miz.michele
    Participant

    delete this entry

    • This reply was modified 11 years, 7 months ago by miz.michele.
    • This reply was modified 11 years, 7 months ago by miz.michele.
    #6241
    miz.michele
    Participant

    Daniel I am soooooooooooo frustrated. Putting in the above code that I put in the pastebin does make the photos link however my entire excerpts- all of them are underlined are a permalink as well.

    I’ve look at few other sites that are using your theme that got their featured images linking and they don’t have the giant permalink for the excerpts.

    Any ideas?

Viewing 15 posts - 1 through 15 (of 17 total)

You must be logged in to reply to this topic.