Display random post custom field
-
I found and adapted this code from another post on this forum but i need some extra functionallity that i cant work out.
<?php $rand_posts = get_posts('cat=8&numberposts=1&orderby=rand'); foreach( $rand_posts as $post ) : ?> <a href="<?php the_permalink() ?>" class="test1"><?php echo get_post_meta($post->ID, "testimonial", true); ?></a> <?php endforeach; ?>
But not every post in category 8 have testimonials so i want to be able to skip the post with no entry. because at the minute i get a blank space when it returns a post with no testiomial.
Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Display random post custom field’ is closed to new replies.