Home » Docs » REST API » /conductor/v1/widget/query/{number}/[paged]/

Description

This REST API route returns query results (in the form of HTML markup for various Conductor Widget sections) for an individual Conductor Widget based on parameters.

Both GET and POST requests can be made to this Conductor REST API route.

Note: We are utilizing the POST request method due to URL length restrictions (~2000 characters) in various browsers. Conductor add-ons may add extra parameters to this Conductor REST API request and we found that, in some cases, the URL could be close to reaching the length restrictions. See https://stackoverflow.com/a/417184 for more information.

Technical Details

  • Type: REST API Route
  • URL Parameters:
    • {number} (int): Conductor Widget number (the WordPress widget number assigned to a Conductor Widget); -1 is allowed for the_widget() (see Query Builder Add-On)
    • [paged] (int) (optional): Paged value, current page to return query results for
  • Extra Parameters (GET or POST):
  • Return Value: JSON object
      • conductor_widget_before (string): HTML markup for the Conductor Widget before wrapper element
      • conductor_widget_title_before (string): HTML markup for the Conductor Widget title before wrapper element
      • conductor_widget_title_after (string): HTML markup for the Conductor Widget title after wrapper element
      • conductor_widget_content_before (string): HTML markup for the Conductor Widget content before wrapper element
      • conductor_widget_content (string): HTML markup for the Conductor Widget content wrapper element (the main widget content)
      • conductor_widget_content_after (string): HTML markup for the Conductor Widget content after wrapper element
      • conductor_widget_pagination (string): HTML markup for the Conductor Widget pagination wrapper element
      • conductor_widget_after (string): HTML markup for the Conductor Widget after wrapper element
      • number (int, string): Widget number (i.e. 1). In some cases this value may be a string if an add-on has modified the widget number (i.e. Query Builder Add-On)
      • widget_id (string): Widget ID; This is the Conductor Widget ID prefix followed by the widget number (i.e. conductor-widget-1)

Request Validation

When a request is made to this REST API route, Conductor will first verify that the Conductor REST API is enabled. If the Conductor REST API is not enabled, a 404 status will be returned with the following code: conductor_rest_api_disabled.

After Conductor has verified that the Conductor REST API is enabled, it will then check to see that the {number} parameter is set to a valid Conductor Widget number. If the {number} parameter isn’t valid, a 404 status will be returned with the following code: conductor_widget_number_invalid.

If the {number} parameter is valid, Conductor will then check to see if the Conductor Widget is enabled in the Conductor REST API. If the Conductor Widget is not enabled in the Conductor REST API, a 404 status will be returned with the following code: conductor_widget_rest_api_disabled.

If all of the above validation checks have passed, a 200 status code will be returned along with the Conductor Widget query results.

Resources

Examples

The following request will return query results for a Conductor Widget with a widget number of 1.

  • /wp-json/conductor/v1/widget/query/1/
  • http://website.com/wp-json/conductor/v1/widget/query/1/

The following request will return page 4 query results for a Conductor Widget with a widget number of 123.

  • /wp-json/conductor/v1/widget/query/123/4/
  • http://website.com/wp-json/conductor/v1/widget/query/123/4/

The following is an example of return data from a request to this REST API endpoint. Some of the return data has been truncated.

The following is an example of return data that has been formatted for better readability. It is not technically valid JSON data due to this formatting.