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 7974599
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T08:25:16+00:00 2026-06-04T08:25:16+00:00

I am using magic fields and have defined a custom post type called collection

  • 0

I am using magic fields and have defined a custom post type called collection with a field called sort, where I input a number I would like to sort the custom posts by.

My WP_Query arguments is simply:

'post_type' => 'collection',
'meta_key' => 'sort',
'order_by' => 'meta_value',
'order' => 'ASC'

Which, upon using print_r on the $query result reveals the following mysql statement:

SELECT SQL_CALC_FOUND_ROWS  wp_posts.* FROM wp_posts  INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id) WHERE 1=1  AND wp_posts.post_type = 'collection' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') AND (wp_postmeta.meta_key = 'sort' ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date ASC LIMIT 0, 10

So I am confused why the generated mysql still contains ORDER BY wp_posts.post_date when I am explicitly stating it should sort by wp_postmeta.meta_key = 'sort' and its corresponding meta_value?

  • 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-04T08:25:18+00:00Added an answer on June 4, 2026 at 8:25 am
    'post_type' => 'collection',
    'meta_key' => 'sort',
    'orderby' => 'meta_value',
    'order' => 'ASC'
    

    order_by = orderby

    Also it’s not called magic fields but custom fields

    http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Wordpress Magic Fields and have a post type with a field
I'm using Custom Post Template which I linked to Magic Fields to create custom
I'm having problems using find*() magic methods of Doctrine2 when the field has an
I have created a C# class file by using a XSD-file as an input.
OK, so I have a database field of type char(1) that has a small
I have an HTML table with input elements that I am using for batch
I have a Rails Table, called Sales, that I would like to render in
I have a form which uploads multiple file fields into a db using codeigniter.
I'm generating images through phpThumb on my Wordpress based website using Magic Fields 2
Using magic strings in C# really unsettles me, so I'm thinking of using 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.