Solved

WordPress Random Post Code

Posted on 2013-01-06
2
562 Views
Last Modified: 2013-01-18
I'm not a programmer. I've been messing around with this for a couple of days after reading many articles online. I hope one of you experts can help me. I'm trying to create a page on a WordPress blog to display all post thumbnails in random order.

The blog is here http://meatbeerbabes.com

The "random post" link on the top-right hand of the header is a "page" that is linked to a page template I created (page-rando-post.php) and it should produce a page similar to the one index.php produces but it should sort all posts randomly.

I do appreciate your help. I've attached two files, index.php and the page template I created (experimented with), page-random-post.php.

Thank you!
index.php
page-random-post.php
0
Comment
Question by:westarinfo
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
sivagnanam chandrakanth earned 500 total points
ID: 38749777
Add this before if(have_post())

query_posts(array(
      'showposts' => 6, //no of posts to display
      'orderby' => 'rand',
'category_name' => 'News' //You can insert any category name //remove tis if you dont need
));
0
 
LVL 12

Expert Comment

by:sivagnanam chandrakanth
ID: 38749778
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question