WordPress.org

Support

Support » How-To and Troubleshooting » How to sort random posts by date?

How to sort random posts by date?

  • Is it possible to display random posts within 30 and omit duplicate post?

    <ul><li><h2>Random Posts</h2>
        <ul>
     <?php
     $rand_posts = get_posts('numberposts=5&orderby=rand');
     foreach( $rand_posts as $post ) :
     ?>
        <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
        </ul>
     </li></ul>

    Thank

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to sort random posts by date?’ is closed to new replies.
Skip to toolbar