Solved

WordPress Random Post Code

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
jQuery Canlendar click function 5 22
modify h2 4 16
php connect() failed error 25 16
Change password through link 1 12
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
The viewer will learn how to dynamically set the form action using jQuery.
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 …

759 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now