Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8078469
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T15:48:20+00:00 2026-06-05T15:48:20+00:00

I cannot get my WordPress theme to randomise the posts I’m displaying in the

  • 0

I cannot get my WordPress theme to randomise the posts I’m displaying in the category archives [I’m using it as a CMS]. The homepage randomises normally, and I am [I think] correctly altering the WP_query. Below is the exact args array:

array(4) { ["orderby"]=> string(4) "rand" ["order"]=> string(3) "ASC" ["posts_per_page"]=> string(2) "-1" ["category_name"]=> string(8) "branding" }

For easier reading it is:

orderby => rand
order => ASC
posts_per_page => -1
category_name => branding (or whatever the query_string brings in)

I get all the posts from the category, but they are in post date order.

Any clues? or alternate methods for shuffling the result of my WP_query in the have_posts?

Thanks.

************EDIT************

Sorry I should have been more clear about the args array above. It is a var_dump of the query array, not my arguments I am adding to the query.

    $args = array(
        'orderby'        => 'rand',
        'order'      => 'ASC',
        'posts_per_page' => '-1',
    );
    global $wp_query;           
    remove_all_filters('posts_orderby');
    $theq = array_merge($args, $wp_query->query);
    query_posts($theq);

I added the remove_all_filters as per Sheikh Heera suggestion, but it hasn’t made a difference.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T15:48:24+00:00Added an answer on June 5, 2026 at 3:48 pm

    You might be better off creating a new query then. This should only be used on an taxonomy template though like category.php or taxonomy-yourcustomtaxonomy.php.

    global $wp_query;
    
    $term = $wp_query->queried_object;
    
    $args=array(
        'orderby' => 'rand',
        'posts_per_page' => -1,
        'post_type' => 'post',
        'tax_query' => array(
                array(
                    'taxonomy'  => $term->taxonomy,
                    'field'     => 'slug',
                    'terms'     => $term->slug,
                    )
                )
        );
    
    $new_query = null;
    $new_query = new WP_Query($args);
    
    while ($new_query->have_posts()) : $new_query->the_post(); ?>
        <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
            <h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <div class="entry-meta"><?php // Meta ?></div><!-- .entry-meta -->
            <div class="entry-content"><?php the_content(); ?></div>
        </div>
    <?php
    endwhile;
    wp_reset_postdata();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing http://pizzli.com/darrenwp as a WordPress Theme. For some reason, I cannot get the
I'm programming a website using Foundation theme for wordpress that is setup for responsive
I'm using the Showtime wordpress theme which builds a blog based on a single
I cannot for some reason get the wordpress /wp-admin pages to execute a simple
I am using a test environment to try to get jquery working in wordpress,
I cannot get my SID working ... <?php session_start(); // Or maybe pass along
I cannot get Bindable LINQ to work with VB.NET for the life of me.
I cannot get the background to stretch behind the contentbox. The strange thing is,
I cannot get the jQuery slideDown function to work on <table> elements. They just
I cannot get the DropDownHeight of the ComboBox set properly to display all the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.