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

  • Home
  • SEARCH
  • 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 8857093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T14:30:34+00:00 2026-06-14T14:30:34+00:00

My query is not ordering my posts using the orderby parameter. A little background:

  • 0

My query is not ordering my posts using the orderby parameter.

A little background:

I’m within a foreach statement that loops through a custom taxonomy for “category” IDs. while in that foreach statement, I am attempting to invoke a new WP_Query getting posts from each “category” of that foreach loop. My args array is as follows:

$args = array(
    'post_type' => 'wpsc-product',
    'post_status' => 'publish',
    'showposts' => -1,
    'tax_query' => array(
        array(
            'taxonomy' => 'wpsc_product_category',
            'field' => 'term_id',
            'terms' => $cat_id,
        ),
        array(
            'taxonomy' => 'series',
            'field' => 'slug',
            'terms' => $series_name
        )
    ),
    'orderby' => 'title',
    'order' => 'DESC'
);

$cat_id and $series_name are both arrays from my custom taxonomies in this post_type.

orderby and order are not working at all and I cannot figure this out why.

  • 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-14T14:30:35+00:00Added an answer on June 14, 2026 at 2:30 pm

    I have checked your code on my test blog. And it works as expected. So parameters

    'orderby' => 'title',
    'order' => 'DESC'
    

    you have set correctly.

    In this situation you can check SQL request.

    $query = new WP_Query($args);
    var_dump($query->request);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible that, using only query statements in my code (and not using
I am using the Select query as SELECT id, ordering FROM `jos_menu` WHERE ordering='.$rec['ordering']
I have a DQL query containing a SELECT expression that's only used for ordering:
i'm using WP_QUERY to get posts. the problem is that i want to sort
this query is simply not ordering results the way i want it to: $sql
why this simple query not working. I know it was OK before I upgraded
Hi I am having an issue with a MySQL query not passing a string
I am tired to find out why this simple query not working. SELECT image_url
My query is not giving proper results when I try to select user records
My Query does not work when I have not set the ProcessorID in myComputer

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.