Best 2 Know

The Ultimate Blogging Resource

  • Advertising
  • WebHosting
  • Contact Us
  • Blogger
    • Blogger Templates
    • Blogger Tutorials
  • Browser
    • Firefox
    • Google Chrome
  • Google
  • Internet
    • Facebook
    • Twitter
  • Thesis
  • Windows
  • WordPress
    • WordPress Themes
    • WordPress Plugins
  • More
    • Linux
    • Review
    • Solutions
    • Announcements

How to Display Random Posts

Want to display Random Posts on your WordPress Blog get more Page views and Help your old Content to be viewed, you probably need Random Post widget or plugin to show it. But why you use some plugin for some Simple work which you can get done inside WordPress easily

Just paste the below code were ever you want to display Random Posts :

<ul>
<?php
$args = array( 'numberposts' => 5, 'orderby' => 'rand', 'post_status' => 'publish', 'offset' => 1);
$rand_posts = get_posts( $args );
foreach( $rand_posts as $post ) : ?>
<li><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2><p><?php the_excerpt(); ?>
</p></li>
<?php endforeach; ?>
</ul>

<ul> <?php $args = array( 'numberposts' => 5, 'orderby' => 'rand', 'post_status' => 'publish', 'offset' => 1); $rand_posts = get_posts( $args ); foreach( $rand_posts as $post ) : ?> <li><h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2><p><?php the_excerpt(); ?> </p></li> <?php endforeach; ?> </ul>

Now you will see the Random Posts, for more customization visit get_posts on WordPress Codex

Subscribe via Email

Share this:

  • Twitter
  • Facebook
  • Pocket
  • Print
  • Email

Related

November 26, 2012 Ritesh Sanap WordPress Hacks, How To, Random Posts, wordpress hacks

Post navigation

Previous Previous post: How to get Start Menu back in Windows 8
Next Next post: How to Load Web Page Faster using Prefetch and Prerender

Currently Trending

  • Windows Vista CD key
  • How to download Specific parts of YouTube videos
  • How to Increase Dropbox upload speed
  • How to add Attribution widget in blogger
  • How to Create Multiple Excerpts in WordPress
  • Random Post Widget for Blogger
  • How To Change Windows XP Shutdown Dialog Box
  • 100+ Best Online Games - Who Else Wants to Play ?
  • List Of All 255 Keyboard All Alt Key Codes
  • How to Change the Welcome/Login Screen in Windows XP ?

Random Posts

Leviathan – Blogger Template

July 16, 2010 By Ritesh Sanap 2 Comments

Simply Pure – WordPress Theme

November 2, 2014 By Ritesh Sanap 2 Comments

Top And Latest High Paying Keywords : Increase Your Adsense Earnings

August 16, 2008 By Ritesh Sanap 1 Comment

Hide or Show Label Count In Blogger

May 2, 2010 By Ritesh Sanap Leave a Comment

Blog Design Series

August 8, 2009 By Ritesh Sanap 9 Comments

WordPress

HTTP2 Server Push for W3 Total Cache Minify plugin

August 17, 2016 By Ritesh Sanap 5 Comments

How to Disable Emojis in WordPress

January 6, 2016 By Ritesh Sanap Leave a Comment

JetPack Related posts and Sharing not working with NGINX

November 10, 2015 By Ritesh Sanap Leave a Comment

Simply Pure – WordPress Theme

November 2, 2014 By Ritesh Sanap 2 Comments

Advanced What should we Write about next? – WordPress Plugin

July 28, 2014 By Ritesh Sanap Leave a Comment

How to Disable Self Pingback or TrackBack

January 16, 2014 By Ritesh Sanap Leave a Comment

BlueStrap – WordPress Theme

January 1, 2014 By Ritesh Sanap 15 Comments

How to Create Multiple Excerpts in WordPress

December 24, 2013 By Ritesh Sanap Leave a Comment

How to Disable Auto Update in WordPress

November 21, 2013 By Ritesh Sanap Leave a Comment

How to Delete Feedbacks from JetPack Contact Form

November 19, 2013 By Ritesh Sanap 9 Comments

Recent Posts

  • HTTP2 Server Push for W3 Total Cache Minify plugin
  • How to show hidden files and folders in Mac OS X
  • How to Disable Emojis in WordPress
  • Canva – Online Photo Editor
  • JetPack Related posts and Sharing not working with NGINX

Archives

Recommends

  • DigitalOcean – Cloud Hosting
  • Dropbox – Cloud Storage
  • Elegant Themes – WordPress Themes
  • LastPass – Password Manager
  • Like us on Facebook
  • Follow on Twitter
  • +1 on Google
  • Subscribe via Email
  • RSS Feed

© 2021 Best 2 Know · All Rights Reserved · We ♥ DigitalOcean

loading Cancel
Post was not sent - check your email addresses!
Email check failed, please try again
Sorry, your blog cannot share posts by email.