Forums

Images in loop not linking to posts (2 posts)

  1. georage
    Member
    Posted 2 months ago #

    On my website, the thumbnails on the home.php page link to larger versions of the image ... not to the post.

    I'd much prefer the thumbnails link to the article.

    My site is smartyweb.org.

    Thanks for any assistance.

    Here is the relevant code ... I have tried various tweaks but have had no success.

    <h3 class="mast">Recent Reviews</h3>
    
    					<?php $the_query = new WP_Query('category_name=reviews&showposts=7&offset=1&orderby=post_date&order=desc');
    
    					while ($the_query->have_posts()) : $the_query->the_post();
    
    					//george added so news and featured posts do not appear under recent reviews
    					if ( in_category( 'featured' ) || ( in_category( 'news' )) ) {continue;}	
    
    					$do_not_duplicate = $post->ID; ?>
    
    					<div class="home_recent_post">
    
    						<?php if ( get_post_meta($post->ID, 'thumb_home_img', true) ) {?>		
    
    						<div class="home_recent_thumb">
    							<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><img src="<?php bloginfo('stylesheet_directory'); ?>/images/thumbs/<?php echo get_post_meta($post->ID, "thumb_home_img", $single = true); ?>" alt="<?php the_title(); ?>" /></a>
    						</div>
    						<?php } else { ?>
    						<div class="home_recent_thumb">
    							<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php
    							the_title(); ?>"><?php if (function_exists('the_thumb')) { the_thumb('altappend=recent_&subfolder=recent&width=48&height=48&keepratio=0'); } ?></a>
    						</div>
    						<?php } ?>
    
    						<div class="home_recent_title" id="post-<?php the_ID(); ?>">
    							<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a>
    						</div>
    
    						<div class="home_recent_date">
    							<?php the_time('F j, Y'); ?>
    						</div>
    
    						<div class="home_recent_auth">
    							By <?php the_author(); ?>
    						</div>
    
    					</div>
    
    					<?php endwhile; ?>
  2. jceresini
    Member
    Posted 2 months ago #

    Your code actually returns something akin to the following for each thumb:

    <a href='post_url'><a href='image_url'><img src='image_thumb'></a></a>

    It looks like your code to grab the thumb image actually returns an image wrapped in an anchor tag. I've never really played with making themes, but hopefully that will point you in the right direction

    [signature moderated Please read the Forum Rules]

Reply

You must log in to post.

About this Topic