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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:30:19+00:00 2026-05-25T16:30:19+00:00

Asked this on another thread and thinking I had gotten a solution marked it

  • 0

Asked this on another thread and thinking I had gotten a solution marked it as solved.

I have a custom post type called courses and have a field within that called pdf-order that basically represents where in the list the post is going to show. I am trying to get it to sort but am having no luck.

This is my code :

$course_loop = new WP_Query( array( 'post_type' => 'course',
                                    'posts_per_page' => 30,
                                    'meta_key' => 'pdf-order',
                                    'orderby'=> 'meta_value',
                                    'order' => 'desc' ) );

Can anyone shed some light on this for me?

Thanks

  • 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-25T16:30:20+00:00Added an answer on May 25, 2026 at 4:30 pm

    Your original query is correct.
    But!

    I also discovered this today in the codex

    I assume your CF ‘pdf-order’ are numbers.
    But wp orders them alphabetically.
    so if we have ‘1,2,3,10,11’
    it will order : 1, 10 , 11, 2, 3
    instead of what you would expect (1,2,3,10,11)

    So add starting zero’s so it would become: ‘001, 002, 003, 010, 011’

    I hope this helps

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

Sidebar

Related Questions

I had this answer on another post I asked: I believe the VS designer
I have asked another question related to this in this thread Where to put
I asked this question in another post - How do I put a <div>
I asked this question earlier. I am intrigued by std::set but I have another
This question is related to another question I asked Basically, I have 2 horizontally
another memory management question: I have asked this before, but did not really get
So I semi-asked this in another thread about how to get .max and return
I asked this question earlier but regarding another programming languages. Let's say I have
I already asked a question about this yesterday, but now I have another :)
(I asked this question in another way , and got some interesting responses but

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.