Support » Themes and Templates » different links for same image

  • Resolved bloggingcss


    Hi all,

    I’m quite new to WordPress, but I think I did a good job at customizing the Kubrick theme over at my brand-new blog.

    I have a technical question though. As you can see on the blog home page, I’ve got big images for each post which of course is the same you see on the post single page. What I’d like to do is make the image on the home page link to the post permalink, so that when I click on it the post page opens up; but once I’m on the single page, I want that same image to link to an external website. How do I do so?

    To get the image on the home page I’m using the_content(), with a “read more” link between the parenthesis (which I customize thanks to the Headspace plugin). Don’t know if this has anything to do with it.

    Hope I can get some help!


Viewing 4 replies - 1 through 4 (of 4 total)
  • edit your index.php and single.php, index.php to link to your permalink(to your post) and single.php(to whatever link you want)

    Im not sure if theres a way to do conditionals within a blogpost,

    A way that would work is if you were to use a custom field and store the url to your photo in each post.

    Then in your index.php file, in your loop pull out the custom field into an image tag and wrap it with an link tag that links to your permalink. Use the except field in to copy the first paragraph of your post and pull the excerpt out in the loop as well.

    Something like this:

    <a href="<?php the_permalink() ?>"><img src="<?php echo get_post_meta($post->ID, pic, true); ?>" alt="<?php the_title(); ?>" border="0" /></a>
    <?php the_excerpt(); ?>

    Hi blogbreaking,

    thanks for your answer. However I don’t think that yours can be a solution since I add the code for the image in the WordPress dashboard, not directly in the index.php file (not all of my posts have that structure).

    Thanks anyway 😉

    I came up with a solution, which turns out to be very similar to the one blogbreaking has posted.

    I found it in this post by Nick La. It’s the snippet under “Custom field”.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘different links for same image’ is closed to new replies.