WordPress.org

Ready to get started?Download WordPress

Forums

Randomise Posts Inside Category (5 posts)

  1. obiemc
    Member
    Posted 4 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. 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

    http://codex.wordpress.org/Function_Reference/query_posts#Orderby_Parameters
    http://codex.wordpress.org/Function_Reference/query_posts

  3. obiemc
    Member
    Posted 4 years ago #

    Thanks will give this a try

  4. obiemc
    Member
    Posted 4 years ago #

    Is this in the theme files?

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

  5. http://codex.wordpress.org/Template_Hierarchy

    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

Tags

No tags yet.