getting a correct link to an image
-
I am trying to display an image from a post and when you click on that image you should go to another page with posts of the same category. I can get the name of the category displayed (the part inside the header) with the correct link (localhost/wordpress/ironwork/tables) as in the code below, but the link to the image insists on going back to the localhost/wordpress rather than localhost/wordpress/ironwork/tables.
if(have_posts()){ foreach($posts as $post){ $category = get_the_category(); $cats = $category[0]->cat_ID; <!-- set up to display in boxes --> <div class="item"> <header> <h2><?php $my_link = get_category_link($cats); $my_cat = get_the_category_by_ID($cats); ?> <a href="<?php echo get_category_link($cats); ?>"> <?php echo get_the_category_by_id($cats); ?> </a> </h2> </header> <?php if(has_post_thumbnail()){ $imgage_url = wp_get_attachment_image_src(get_post_thumbnail_id() ,'medium'); ?> <a href="<?php get_category_link($cats); ?> " title="<?php the_title_attribute(); ?>"> <?php echo the_post_thumbnail('medium'); ?> </a> <?php } ?> </div> <!-- class=item -->
I have tried replacing the line
<?php echo the_post_thumbnail('medium'); ?>
with<img src='$image_url[0]' ></img>
without success. Is what I’m trying to do not possible? Does WP do something behind my back to insist that the link to the post thumbnail be what it wants or am I doing something stupid which is also possible?
- The topic ‘getting a correct link to an image’ is closed to new replies.