Randomise Posts Inside Category (5 posts)

  1. obiemc
    Posted 5 years ago #

    Hello im just wondering if there is a way to have the posts inside my categories randomise every time you click into it.

    What it is i have advertisers saying there at the bottom as they have been with us a long time and new adverts are at the top.

    So would be great if it could change every time you go into it.

  2. Michael
    Forum Moderator
    Posted 5 years ago #

    try to add something like this:

    <?php global query_string;
    query_posts($query_string . '&orderby=rand'); ?>

    before the start of the loop in category.php (or archive.php) of your theme


  3. obiemc
    Posted 5 years ago #

    Thanks will give this a try

  4. obiemc
    Posted 5 years ago #

    Is this in the theme files?

    As i dont have either category.php or archive.php in there?

  5. Michael
    Forum Moderator
    Posted 5 years ago #


    themes don't neccessary need a archive.php, or category.php;
    however, if you want to make specific modifications in the category page, it helps to have this category.php.

    to make one, create a new file in your theme with the name category.php and paste the whole code from index.php into it.

    then make the edits in category.php

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.