In the minute my slider (s3Slider JQuery) calls and shows the final 5 posts. It grabs the pictures from the custom area labelled 'thumb'.
I would like rather for that slider to simply call images which have something within the 'thumb' custom area. Is possible?
<?php $my_query = new WP_Query('showposts=5'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <li class="sliderImage"> <a href="<?php the_permalink() ?>" rel="bookmark"> <img class="featimg" src="<?php echo get_post_meta($post->ID, 'thumb', true) ?>" alt="<?php the_title(); ?>" /> <span class="des"><h1><?php the_title(); ?></h1><?php the_excerpt(); ?></span> </a> </li> <?php endwhile; ?>
Thanks ahead of time.
You are likely to want to modify your Wordpress_Query towards the following (note this only works best for Wordpress >= 3.1):
$my_query = new WP_Query( array( 'posts_per_page' => '5', 'meta_query' => array( array( 'key' => 'thumb', 'value' => '', 'compare' => '!=' ) ) ) );
Obviously, if a person makes its way into something that is not a legitimate road to a picture (e.g. 'blahblah'), this it's still passed for your
<img> in your
<li> element, so you might want to perform some further checking/error handling when processing the input in the WordPress after sales.