• bencarter78

    (@bencarter78)


    Hi there

    I’m trying to create a loop of all my custom post titles and their custom fields. I want to order them by a custom field called ‘vacancy-company’ but it just lists them by post date.

    Here’s my code…

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Can someone tell me what I’m doing wrong please?!!!

    Thank you!

Viewing 1 replies (of 1 total)
  • vtxyzzy

    (@vtxyzzy)

    Since I can’t see your code, I can’t be sure, but you should probably be able to add a couple of arguments to your query_posts(), something like this:

    $args = array(
       'paged' => $paged,  // Assuming this was already there
       'meta_key' => 'vacancy-company',  // Add this
       'orderby' => 'meta_key',  // Add this
       'order' => 'ASC',  // Probably need this
    );
Viewing 1 replies (of 1 total)
  • The topic ‘Ordering Custom Post Types by Custom Fields’ is closed to new replies.