WordPress.org

Ready to get started?Download WordPress

Forums

JSON API
[resolved] Order by custom field (2 posts)

  1. cristophergv
    Member
    Posted 10 months ago #

    Hello world,

    I have two questions, you can sort the results by alphabetical order data basing on a custom field?. For example if I have type values ​​STATUS: Water, Glass, I returns all data starting with water for example.

    On the other hand, you can retrieve only the posts which custom field has a value STATE: WATER??

    Thank you very much everyone :)

    Happy day.

    http://wordpress.org/plugins/json-api/

  2. cristophergv
    Member
    Posted 10 months ago #

    Well, I answered myself.

    To sort the posts in alphabetical order by custom field are passed as parameters to the query: orderby = meta_value & meta_key = Custom field name & order = ASC or DESC. Example:

    http://127.0.0.1/wordpress/api/get_category_posts/?orderby=meta_value&meta_key=estado&order=ASC

    or

    http://127.0.0.1/wordpress/api/get_posts/?orderby=meta_value&meta_key=estado&order=ASC

    And to get only posts that have some custom field values ​​is adding: meta_key = custom field name & meta_value = value to be searched. Example:

    http://127.0.0.1/wordpress/api/api/get_posts/?meta_key=estado&meta_value=colima

    Good luck world.

Reply

You must log in to post.

About this Plugin

About this Topic