WordPress.org

Ready to get started?Download WordPress

Forums

Featured Image External Link (7 posts)

  1. cedaly1968
    Member
    Posted 1 year ago #

    I want the featured image on each blog post to have a redirect to my e-commerce web-site. This is the code that I am using and what is happening is that the image is showing two thumbnails on the post. One thumbnail links to the web-site and one thumbnail links to the image itself (permalink). I am PHP hobbled - any thoughts?

    <div class="imageframe-1">
    <?php $key="featured_external"; $single=1; $custom = get_post_meta($post->ID, $key, $single); ?>

    if($custom == ""){
    " title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> ;}
    else{
    " title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?> ;}

    </div>

  2. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    please re-post your code - this time marking it according to forum guidelines http://codex.wordpress.org/Forum_Welcome#Posting_Code - to keep it from getting mangled by the forum's parser.

  3. cedaly1968
    Member
    Posted 1 year ago #

    <div class="imageframe-1">
    <?php $key="featured_external"; $single=1; $custom = get_post_meta($post->ID, $key, $single); ?>  
    
    if($custom == ""){
    	<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?></a> ;}
    else{
    	<a href="<?php echo $custom; ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?></a> ;}
    
                				</div>

    Sorry - forgot to post the backticks!@ D'oh!!!!!

  4. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    there were some php tags missing in the code:

    <div class="imageframe-1">
    <?php $key="featured_external"; $single=1; $custom = get_post_meta($post->ID, $key, $single); ?>  
    
    <?php if($custom == ""){ ?>
    	<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?></a> <?php ;}
    else{ ?>
    	<a href="<?php echo $custom; ?>" title="<?php the_title(); ?>"> <?php the_post_thumbnail(); ?></a> <?php } ?>
  5. cedaly1968
    Member
    Posted 1 year ago #

    Thanks SWEEPER! That did the trick. Mental note to self, don't write PHP at night when your kids are on your lap! Thanks again!

  6. nicnack
    Member
    Posted 1 year ago #

    how do you set the external link per featured image?
    where exactly is this code placed?
    thanks

  7. mikemayhem3030
    Member
    Posted 1 year ago #

Topic Closed

This topic has been closed to new replies.

About this Topic