• 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

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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();
     ?>

    my posts in a child category

    or

    for all my categories

    which is it?

    Thread Starter richwalker

    (@richwalker)

    Sorry its a child category

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Random’ is closed to new replies.