• In my wordpress theme i have this code,

    <?php query_posts(array('post__in' => get_option('sticky_posts'), 'post_status' => 'publish', 'orderby' => 'rand')); ?>

    this is very slow, is there any faster way to do this.

Viewing 1 replies (of 1 total)
  • Moderator t-p

    (@t-p)

    try this, add where you want show the random post:

    <ul>
    <li><h2>A random selection of my writing</h2>
    
    <ul>
     <?php
     $rand_posts = get_posts('numberposts=5&orderby=rand');
     foreach( $rand_posts as $post ) :
     ?>
    
    <li><a>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
Viewing 1 replies (of 1 total)
  • The topic ‘faster way to show random post’ is closed to new replies.