[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

WordPress Random Post Code

Posted on 2013-01-06
2
Medium Priority
?
576 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 12

Accepted Solution

by:
sivagnanam chandrakanth earned 2000 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

Featured Post

Looking for a new Web Host?

Lunarpages' assortment of hosting products and solutions ensure a perfect fit for anyone looking to get their vision or products to market. Our award winning customer support and 30-day money back guarantee show the pride we take in being the industry's premier MSP.

Question has a verified solution.

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

3 proven steps to speed up Magento powered sites. The article focus is on optimizing time to first byte (TTFB), full page caching and configuring server for optimal performance.
This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
The purpose of this video is to demonstrate how to reset a WordPress password if you are locked out and cannot reset the password. A typical use would be if you cannot access the email to which WordPress would send the password recovery email to…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

650 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