Using query_args with Custom Fields

Community Forums Forums Design Tips and Tricks Using query_args with Custom Fields

This topic is: resolved

Tagged: 

This topic contains 3 replies, has 2 voices, and was last updated by  rfmeier 1 year, 4 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #46426

    csbeck
    Participant
    Post count: 135

    I’m modifying the Agency theme on this site in production:

    http://grglaw.beckerstudio.com/our-professionals

    This page shows a Blog listing of Posts in the “Professionals” category – I get this by using the query_args in the custom fields area. I’m using this value in the query_args key:

    `cat=2&orderby=title&order=ASC`

    It shows the posts that I want but I want to have the posts sorted in alphabetical order by their LAST name. I was thinking of the following options:

    • Set the publication date of the posts in the order that I want (not user friendly for the client)

    or

    • Create some type of custom field key and value to sort the posts by

    Does anyone know of a good/quick way to do this with query_args or do I need to create a custom Blog Listing page template?

    Thanks for your input. Chris

     

    http://grglaw.beckerstudio.com/our-professionals
    #46428

    rfmeier
    Participant
    Post count: 597

    Chris,

    If you are sorting by custom meta, you can use these parameters specified within the WordPress documentation.

    http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters

    I hope this points you in the right direction.


    #46434

    csbeck
    Participant
    Post count: 135

    Thanks Ryan. I did visit that page and it was a bit vague on the syntax. I wasn’t sure how to represent the key name and such.

    So I tried another go at it. I was successful with the following:

    `cat=2&orderby=meta_value&meta_key=last_name&order=ASC`

    So this took my manually entered Custom Field values assigned to the key “last_name” and sorted them alphabetically (since they were alpha characters). Thanks for the link and nudge to try it again.

     

    #46435

    rfmeier
    Participant
    Post count: 597

    You are welcome. Good luck.


Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.