REST API result sorting

This topic contains 15 replies, has 3 voices, and was last updated by  D.D 7 years, 3 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #345596

    D.D
    Buyer
    Post count: 199

    Hi,

    How do I get the results from the GET method for the REST API to be sorted by the endpoint orderby”: {
    “required”: false,
    “default”: “overall_rating_desc”,
    “enum”: [
    “overall_rating_desc”,
    “rating_count_desc”,
    “post_title_asc”,
    “post_title_desc”
    ].

    I’ve tried a few options but none seem to work.

    Thanks.

    #345853

    Paolo
    Site Admin
    Post count: 31206

    Hi,

    I flagged your request for the developer of the API add-on. He’ll let you know asap.

    Thanks

    #348421

    Kiran
    Moderator
    Post count: 7069

    Hi,

    The sorting problem has been fixed, please download most recent addon from here https://github.com/GeoDirectory/geodir_api

    Use orderby parameter to sorting listings for specific order.
    Ex: wp-json/geodir/v1/places/&orderby=overall_rating_desc

    Parameter orderby should contains option from orderby schema.

    Thanks,
    Kiran

    #348868

    D.D
    Buyer
    Post count: 199

    Thanks for the update, I’ll test out the call and let you know, however my search calls no longer work after the updating the plugin.

    #348870

    Kiran
    Moderator
    Post count: 7069

    Please provide your site api url in private reply, so i can look into.

    #348871

    D.D
    Buyer
    Post count: 199
    This reply has been marked as private.
    #348898

    Kiran
    Moderator
    Post count: 7069

    Hi,

    Please overwrite file https://raw.githubusercontent.com/kprajapatii/geodir_api/5c5853fc9808e59434305c868d00d19df1c195da/includes/geodir-rest-listings-functions.php

    at path plugins/geodir_api/includes/geodir-rest-listings-functions.php

    Let us know.

    Thanks

    #348907

    D.D
    Buyer
    Post count: 199

    The search function is works now but the orderby endpoint no longer has the options that I referenced in the first post. It’s now “orderby”: {
    “required”: false,
    “default”: “date”,
    “enum”: [
    “date”,
    “relevance”,
    “id”,
    “include”,
    “title”,
    “slug”
    ],
    “description”: “Sort collection by object attribute.”,
    “type”: “string”

    so I can’t get results by overall rating.

    #349052

    Kiran
    Moderator
    Post count: 7069

    Let us provide FTP details to look into. I can’t re-create it in my test site.

    Thanks

    #349060

    D.D
    Buyer
    Post count: 199
    This reply has been marked as private.
    #349808

    Kiran
    Moderator
    Post count: 7069

    Hi There,

    Please check now.

    FYI: The WP REST API plugin is no longer need now, because since WP has included built in REST API endpoints since 4.7.

    Thanks,
    Kiran

    #349853

    D.D
    Buyer
    Post count: 199

    yeah it works now with the http://www.domain.com/wp-json/geodir/v1/places?gd_placecategory=96&orderby=overall_rating_desc&per_page=10

    however my search calls are not sorting by overall rating using

    http://www.aretego.com/wp-json/geodir/v1/places?search=somesearchkey&orderby=overall_rating_desc&per_page=10

    The search results are not sorted properly or am I doing something wrong?

    Cheers.

    #350168

    Kiran
    Moderator
    Post count: 7069

    For the search results, the first priority for sorting is best matching criteria and then it applies your sorting as a second priority.

    Thanks,
    Kiran

    #350206

    D.D
    Buyer
    Post count: 199

    Ok great! I’ve just noticed a change in my search results. Results used to include matches with place tags before just like the website but now doesn’t return those results. How do I fix that?

    Thanks.

    #350207

    Kiran
    Moderator
    Post count: 7069

    The current searching functionality extended to standard WP REST API, i mean our plugin uses WP standard search criteria that WP REST API uses.

    I have already added to-do to use our own search criteria just we have used in website search.

    Kiran

Viewing 15 posts - 1 through 15 (of 16 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket