Random Post from a Specific Category not working in 2.6
I have been using this code in WordPress 2.5.1 in order to generate a custom field called testimonial randomly from a certain category:
<?php $rand_posts = get_posts('cat=7&numberposts=1&orderby=RAND()'); foreach( $rand_posts as $post ) : ?> <em>"<?php echo get_post_meta($post->ID, "testimonial", true); ?>"</em> <?php endforeach; ?>
This display a particular custom field from posts in category 7 randomly so they change on each page and refreshes.
The problem is that now I have upgraded to WordPress 2.6 this no longer gives a random post but just delivers the latest post from the category 7. Anyone any ideas why?
- The topic ‘Random Post from a Specific Category not working in 2.6’ is closed to new replies.