WordPress.org

Ready to get started?Download WordPress

Forums

Featured Image - Outbound Link (13 posts)

  1. erickeel
    Member
    Posted 1 year ago #

    I would like for a Featured Image to link to an external site. I've found many plugins that do the opposite, where you can find an external link that will "bring in" an image, but that's not what I'm looking for.
    I have a Featured Image on site http://www.blah.blah, but would like to link that image to www. notblah.notblah . How do I do this...lol?

  2. erickeel
    Member
    Posted 1 year ago #

    anybody got anything?

  3. Marco Milesi
    Member
    Posted 1 year ago #

    Depending on your theme, you should modify the associated .php file.
    If you want your posts' featured image to link an external site, then look for the single.php file.

    I don't think you will find this kind of plugins :/ since these functions are triggered from your template!

  4. erickeel
    Member
    Posted 1 year ago #

    <ul class="portfolio">
    
    				<?php
    
    				query_posts('category_name=portfolio&posts_per_page=50');
    
    				if (have_posts()) : while (have_posts()) : the_post();
    
    		 		// if URL else #
    			 	$url = get_post_meta($post->ID, 'URL', false);
    		 		$url = (isset($url[0]) ? $url[0] : '#');
    
    				$category = get_the_category();
    
    				if($category[0]->slug == 'projects')
    					echo '<li class="default toggle" data-open="projects">';
    				else
    					echo '<li class="'.$category[0]->slug.'">'
    				?>
    					<a>">
    						<?php
    						if(has_post_thumbnail())
    							the_post_thumbnail('thumbnail');
    
    						if($category[0]->slug == 'projects'){ ?>
    						<span>
    							<strong><?php echo get_the_title() ?></strong>
    							<?php echo get_the_excerpt() ?>
    						</span>
    						<?php } else { ?>
    						<span>on <?php echo $category[0]->cat_name?></span>
    						<?php } ?>
    					</a>
    
    				<?php endwhile; endif;
    				previous_comments_link();
    				wp_reset_query(); ?>
  5. erickeel
    Member
    Posted 1 year ago #

    I found this, but I don't know what to add/delete to allow the outbound link.

    I also found this on an existing forum, but am unable to figure out how to merge the two...

    <?php query_posts( 'cat=Featured&posts_per_page=5' ); if( have_posts() ) : while( have_posts() ) : the_post(); ?>
    <?php $key="featured_external"; $custom = get_post_meta($post->ID, $key, true); ?>
    
    	<?php if(has_post_thumbnail()) {
    			if($content = $post->post_content ) { ?>
    				<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    				<?php the_post_thumbnail(); ?>
    				</a>
    					<?php } else { ?>
    					<a href="<?php $key="featured_external"; echo get_post_meta($post->ID, $key, true); ?>" title="<?php the_title(); ?>">
    					<?php the_post_thumbnail(); ?>
    					</a>
    					<?php }  ?>
    	<?php }  ?>
    	<?php endwhile; endif;?>

    Here's my sight: http://www.servantdesign.com
    and I would like the 15 pictures in the "Work" Section to link elsewhere.

  6. Marco Milesi
    Member
    Posted 1 year ago #

    So, try something like this:

    <a href="http://yourlink" title="yourtitle">
    <?php the_post_thumbnail(); ?></a>

    PPs. Where would you take your link from?

  7. erickeel
    Member
    Posted 1 year ago #

    I added a custom field where I added the link for each picture, but it doesn't seem to be communicating back and forth.

  8. Marco Milesi
    Member
    Posted 1 year ago #

    Well, if those images i see are different posts and you don't need your visitors to see the single view of them, then try this plugin:
    http://wordpress.org/extend/plugins/quick-pagepost-redirect-plugin/

  9. erickeel
    Member
    Posted 1 year ago #

    Ok, I reinserted the original index.php file/ each pic is a different post / and each category (5pics) will link to a separate link.

  10. erickeel
    Member
    Posted 1 year ago #

    Does that plugin work with a post that only includes a featured image? No text, just the featured image.

  11. Marco Milesi
    Member
    Posted 1 year ago #

    Instead of opening your posts' single view, this plugin redirect you to another url that you decide (no matter if there is some text in there)... I haven't it installed, but i suggest you to give it a try!

  12. erickeel
    Member
    Posted 1 year ago #

    Yeah, I installed it, but it is still redirecting me back to mywebsite.com/#

  13. erickeel
    Member
    Posted 1 year ago #

    It's almost like something in the index.php is overriding it...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.