WordPress.org

Forums

Random Post from a Specific Category not working in 2.6 (3 posts)

  1. educationthemes
    Member
    Posted 7 years ago #

    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?

  2. hungzai
    Member
    Posted 7 years ago #

    Exactly. This doesn't work in 2.6 anymore! I kinda regret upgraded it!

    *Update

    This works for me.
    http://wordpress.org/support/topic/195539?replies=3

  3. hungzai
    Member
    Posted 7 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic