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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:54:52+00:00 2026-05-29T06:54:52+00:00

I have a custom post type called song and i want to query the

  • 0

I have a custom post type called song and i want to query the wordpress database to return all the songs from a particular album and then sort them by track number. I have the following code

$args = array(
'post_type'=>'song',
'meta_key'=>'song_album',
'meta_value'=>'album title'
);
$query = new WP_Query($args);

this will successfully return all the songs from the album and I could switch it to this

$args = array(
'post_type'=>'song',
'meta_key'=>'song_track_number',
'order_by'=>'meta_value_num'
);
$query = new WP_Query($args);

which returns all the songs sorted by track number but not filtered by album. What I need to do I sort the results by one meta_key and order them by another but I’m only allowed one meta_key. Does anybody know how I can accomplish this?

  • 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-05-29T06:54:52+00:00Added an answer on May 29, 2026 at 6:54 am

    Maybe this helps http://www.mattvarone.com/wordpress/query-multiple-meta-values/

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

Sidebar

Related Questions

I have created a custom post type called banners and want to enable the
I observed that if I have a custom post type called article, the links
I am using magic fields and have defined a custom post type called collection
Ok i have a custom post type on my blog called videos, where i
I can outputting all of my posts in a custom post type called Featured
I have a custom post type called films and most films have a subpage(child)
I have a WordPress custom post-type setup. I've created single-[customposttype].php However instead of displaying
I have a series of posts within a custom post type which are all
I made some meta_values under a custom post type called 'Show'. I have confirmed
i have created a custom post type named Books & i have a widget

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.