[resolved] how to have images AND links in same custom field? (4 posts)

  1. mixmastermichael
    Posted 4 years ago #

    Hi there, so I successfully know how to add IMAGES as a custom field for a page template, and also how to add LINKS as a custom field on a page template... but, how do I have a custom field so that the IMAGE LINKS to whatever I want to add in the custom field???

    Please let me know if that does not make sense. I am happy to clarify.

    Thanks for any help.

  2. vtxyzzy
    Posted 4 years ago #

    I am assuming that you are putting the URL of an image in your Custom Field. If that is correct, you could have code like this in your template:

    $image = get_post_meta($post->ID,'image-url',true);
    echo "<a href='$image' title='Link to $image'><img src='$image' alt='Link to image' /></a>";
  3. mixmastermichael
    Posted 4 years ago #

    thanks for the reply... got me on the right track :-)

  4. vtxyzzy
    Posted 4 years ago #

    If your problem has been solved, please use the dropdown on the right to mark this topic 'Resolved' so that anyone else with this question can see that there is a solution.

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.