Ask your WordPress questions! Pay money and get answers fast! (more info)

Generate RANDOM posts in KARMA Theme WordPress

Hi,

Using the Karma Theme for a community portal.

Have a full width slider and below that a four column layout which pulls posts from a partcular category.

By default, the latest four posts get pulled.

However, the older posts get ignored by new visitors.

I would therefore like to pull posts from any category(ies) using the RAND command or any other code so that any four RANDOM posts are pulled.

In addition I would like a button at the bottom of the four columns which, when clicked, would REFRESH the four posts above with a fresh set of four random posts.

Look forward to your solution. Thanks.
Marzban

Answers (2)

2013-05-09

Arnav Joy answers:

are you talking about the home page slider?


Arnav Joy comments:

open these two files

template-homepage-jquery
template-homepage-jquery-2

and find following line:-

$query_string ="posts_per_page=100&cat=$jcycle_category_id"

replace it with

$query_string ="posts_per_page=100&cat=$jcycle_category_id&orderby=rand";

you have to add "&orderby=rand" at last to show posts randomly

and if you want to use any category then you have to remove "cat " parameter from the above query string ,so your final string will be like

$query_string ="posts_per_page=100&orderby=rand";

if you are using child theme then you should apply these changes to child theme not to karma otherwise your changes will be lost when you will upgrade it.

let me know if you have any problem doing it.

2013-05-09

Daniel Yoen answers:

Hello,

also, you can try edit "theme-template-part-content-blog.php" file

add this line :

query_posts(array("orderby" => "rand"));

above :

if (have_posts()) : while (have_posts()) : the_post();

hope this help :-)