Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #200497

    Hi,

    I have created a custom field for posts called ‘external_url’.
    Is there a way to wrap url in this field around the featured image, so clicking the featured image will take the user to the external site rather than showing a larger version of the featured image?

    kindest regards,

    PPCHound

    #200595

    Hey PPCHound!

    Yes – open up /wp-content/themes/enfold/includes/loop-index.php and replace

    
            //on single page replace the link with a fullscreen image
            if(is_singular())
            {
                $link = avia_image_by_id(get_post_thumbnail_id(), 'large', 'url');
            }
    

    with

    
            //on single page replace the link with a fullscreen image
            if(is_singular())
            {
                $link = avia_image_by_id(get_post_thumbnail_id(), 'large', 'url');
            }
    
            $external_link = get_post_meta($the_id, 'external_url');
            if($external_link) $link = $external_link;
    

    Cheers!
    Peter

    #200710

    Hi Peter,

    Many thanks for your reply.

    I tried your code change, and the expected url contained within the custom field was not applied. Instead received

    <a href="Array"><img /></a>

    Seems to see the external_url as an array. Hmm … Any thoughts appreciated.

    kindest regards,

    PPCHound

    • This reply was modified 11 years ago by PPCHound.
    #200960

    Hi,

    Can you create an administrator account and post it here as a private reply?

    Regards,
    Josue

    #201070
    This reply has been marked as private.
    #201226
    This reply has been marked as private.
    #201248
    This reply has been marked as private.
    #201260

    Using the code Peter provided, i just modified this line:
    if($external_link) $link = $external_link;

    To this:
    if($external_link) $link = $external_link[0];

    So it will get the first item of the Array.

    Best regards,
    Josue

    #201264
    This reply has been marked as private.
Viewing 9 posts - 1 through 9 (of 9 total)
  • The topic ‘Post Featured Image links to external URL?’ is closed to new replies.