• Resolved jesters94

    (@jesters94)


    I am using Sportspress Pro and it was suggested I use WPGetAPI to create custom scripts.

    I have the free version installed and so far have managed to get it to create a test script called Test Player with an endpoint of [wpgetapi_endpoint api_id=’test_player’ endpoint_id=’player_test’ debug=’false’ format=’html’]

    It pulls all of the data through, however how would I add a query string or something else to select only the “Title” which is the player name and then sort by A to Z, rather then pull all of the data through?

    Tried to follow the online documentation but think I have confused myself too much

    Any advice appreciated

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Support Nikunj Hatkar

    (@nikunj8866)

    Hi

    Thank you for reaching out.

    Please refer to our documentation here: https://wpgetapi.com/docs/adding-query-string-parameters/ for details on how to pass data to the API as parameters.

    If it’s still not working as expected, could you please share screenshots of your endpoint setup here: https://wpgetapi.com/support-ticket/?

    This will help me review the setup and guide you accordingly.

    Thank you.

    Thread Starter jesters94

    (@jesters94)

    Image below for ease

    Query String id : 2977

    https://solihulljestersicehockey.co.uk/wp-content/uploads/2025/08/Query_String.png

    Players Schema from Sportspress Pro

    id
    integerUnique identifier for the object.
    <small>Read only</small>
    Context: vieweditembed

    https://support.themeboy.com/article/278-players

    Plugin Support Nikunj Hatkar

    (@nikunj8866)

    Thank you for sharing the details and the schema. I’ve reviewed the API article you mentioned.

    If you want to fetch the details of a particular player, then instead of using a query string you’ll need to pass the ID directly in the endpoint. Please see this reference screenshot: https://prnt.sc/ICgN_mSWzraW.

    Since the Sportspress Players API follows the WordPress Post REST API standard, you can query it in the same way as WordPress posts. For example, you can search players by Title see this reference screenshot: https://prnt.sc/2kIbS8_Iuzlb

    For sorting or ordering players (e.g. by Title A–Z), you can use the standard WordPress Post REST API query parameters like order and orderby in Query String.

    And you can find the full list of available parameters here: https://developer.wordpress.org/rest-api/reference/posts/#list-posts

    Thank you.

    • This reply was modified 7 months, 2 weeks ago by Nikunj Hatkar.
    Thread Starter jesters94

    (@jesters94)

    Thank you for coming back to me. This is useful and I am getting my head around the query strings.

    For the player ID query is there a way I can run a query that only pulls through the player name, ie ID, and not all of the data for the said player? With all of the data, showing the leagues, games, scores etc it covers a lot of pages.

    Second question is there a way to loop the query to show all player names (IDs)?

    Plugin Support Nikunj Hatkar

    (@nikunj8866)

    Hi

    For your first question, if you only want to display a specific field such as the player name from the full API response, please see our documentation here: https://wpgetapi.com/docs/retrieve-nested-data/. This feature is available in the PRO version of WPGetAPI. If you are comfortable with coding, you can also use the wpgetapi_raw_data and wpgetapi_before_retrieve_body hooks to filter or modify the API response before it is displayed.

    For your second question, the /sportspress/v2/players endpoint follows the standard WordPress REST API for posts. By default, it will return 10 results per request, but you can use the per_page parameter to increase this up to a maximum of 100 results in a single request.

    Thank You.

    Thread Starter jesters94

    (@jesters94)

    Hi Again,

    Sorry I have tried to get the query from this help but I am getting myself lost and at the moment I cannot justify the PRO version if I cannot get this to work

    I used the endpoint of /wp-json/sportspress/v2/players/2977 as shown in your previous response and it does list all of the data held, however I only want to list the “id” and then loop it through all that are of ‘status=published’

    Plugin Support Nikunj Hatkar

    (@nikunj8866)

    Hi

    You can use the WordPress REST API’s _fields parameter to fetch only specific fields. For example, if you want to return just the id, you can call:
    /wp-json/sportspress/v2/players/2977?_fields=id

    Here’s a screenshot of the setup and response using WPGetAPI for reference:
    https://prnt.sc/OMYRuqWcsve7
    https://prnt.sc/xOWWV1XRovpD

    Thread Starter jesters94

    (@jesters94)

    Perfect thank you for this. I tried it last night and also played around with other items like orderby, order etc

    I watched a Youtube video on using Postman and then Jsonviewer and have now managed to start using the WPdatatables pluggin

    Plugin Support Nikunj Hatkar

    (@nikunj8866)

    That’s great to hear!

    If you run into any further questions while refining your setup, just let us know and we’ll be happy to help.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Help on creating a Query String’ is closed to new replies.