Solved

WordPress Random Post Code

Posted on 2013-01-06
2
564 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 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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 viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

733 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