WordPress.org

Forums

making a clickable image (14 posts)

  1. nicnack
    Member
    Posted 2 years ago #

    Hi! I am looking for the PHP code to make an image clickable to its own post. How can this be written in PHP so that it does this? thanks a ton to all of you wordpress geniuses :)

  2. nicnack
    Member
    Posted 2 years ago #

    let me clarify. I mean the post or project that the image is in.. not simply click to a post of itself. thanks!

  3. Aaron
    Member
    Posted 2 years ago #

    Can you explain a little more on what you are trying to do?

    Is this going in a template file? How will it know what link/post to enter? Are you using custom fields?

  4. nicnack
    Member
    Posted 2 years ago #

    basically it's for a 'portfolio' section that has it's featured image displayed on the homepage, but it's thumbnail on the homepage doesn't click to it's post. does that make sense?

  5. nicnack
    Member
    Posted 2 years ago #

    I would love to make a small icon in the corner of the featured image that clicks to the post/portfolio that the featured image is from

  6. Aaron
    Member
    Posted 2 years ago #

    Find the code in your template that is the link portion that heads to the portfolio.

    Copy the link and wrap it around the <img /> that creates the thumbnail.

  7. nicnack
    Member
    Posted 2 years ago #

    but how can I specify each individual post link?

  8. Andrew
    Forum moderator
    Posted 2 years ago #

    Doesn't the visual editor in the dashboard give you an option to hyperlink the image?

  9. Aaron
    Member
    Posted 2 years ago #

    We wouldn't be able to help unless we can see the site and the code in your template that is creating the portfolio.

  10. nicnack
    Member
    Posted 2 years ago #

    Hm, I am working on mamp on my local computer so I don't have it at a live link to post right now. could I post my code here?

  11. Aaron
    Member
    Posted 2 years ago #

    Do it on http://pastebin.com/ and paste the link to that here if it is long. Under 10 lines of code just paste it here and wrap in the code tag you see in the editor.

  12. nicnack
    Member
    Posted 2 years ago #

    awesome. thanks for telling me about pastebin!

    the header code: http://pastebin.com/ERaB90A7
    index code: http://pastebin.com/70bFqA6u
    functions code: http://pastebin.com/0nhTQYWK

  13. nicnack
    Member
    Posted 2 years ago #

    hi there ! no luck or is it just a busy day?

  14. nicnack
    Member
    Posted 2 years ago #

    got it!
    <?php the_permalink(); ?>
    that's all I needed :)

Topic Closed

This topic has been closed to new replies.

About this Topic