Custom Field outside the loop and inside an array
-
I am trying to use a Custom Field called Thumbnail on a Widget so it’s therefore outside the loop. Taking it a step further, the theme I have is using an array to generate listings which confuses me on how to get this to work.
Basically, the theme uses Feature Image to display thumbnails of each post and I want to use a Custom Field. Here is the piece of coding I need to change:
<?php if($images && has_post_thumbnail()): ?> <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'widget-image'); ?> <div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php echo $image[0]; ?>" alt="<?php the_title(); ?>" width='290' height='160' /></a><?php echo $icon; ?></div> <?php else: ?> <div class="block-image"><a href='<?php the_permalink(); ?>' title='<?php the_title(); ?>'><img src="<?php bloginfo('template_directory'); ?>/timthumb.php?src=<?php bloginfo('template_directory'); ?>/images/thumbnail.png&w=290&h=160" alt="<?php the_title(); ?>" width='290' height='160' /></a><?php echo $icon; ?></div> <?php endif; ?>
This is inside a counter with an array.
This seems easy enough to do but I my programming skills are very limited. I don’t know PHP or WordPress very well especially when it comes to outside the loop and using arrays.
Here is the entire code on the widget page:
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Field outside the loop and inside an array’ is closed to new replies.