WordPress.org

Ready to get started?Download WordPress

Forums

Random (4 posts)

  1. richwalker
    Member
    Posted 1 year ago #

    Hi

    I am trying to make my posts in a child category show in a random order. I have this query post below but this only works for the category "The Category". How do i do it for all my categories?

    <?php

    query_posts(array(
    'orderby' => 'rand',
    'category_name' => 'The Category'
    ));
    if (have_posts()) : while (have_posts()) : the_post();
    ?>

    Thanks

  2. deepbevel
    Member
    Posted 1 year ago #

    try removing

    'category_name' => 'The Category'

    from the array.
    just remember to remove the comma from the last argument in the array, which in your case there's only one left,so no comma.

    <?php
    
    query_posts(array(
     'orderby' => 'rand'
     ));
     if (have_posts()) : while (have_posts()) : the_post();
     ?>
  3. alchymyth
    The Sweeper & Moderator
    Posted 1 year ago #

    my posts in a child category

    or

    for all my categories

    which is it?

  4. richwalker
    Member
    Posted 1 year ago #

    Sorry its a child category

Topic Closed

This topic has been closed to new replies.

About this Topic