WidgetCoreWidgetCore Documentation

REST API

Every WidgetCore REST route in one place — the single public search endpoint, what it is for, the rules REST clients follow, which features use no REST at all, and a quick check that it works.

WidgetCore has exactly one REST route: the one the Live Search widget and the [wgcr_search] shortcode use to fetch results. It is public and documented, so you can call it from your own JavaScript, a mobile app or another plugin. This page lists every route and the rules they share. A route that needs a longer explanation has its own page under this one.

All REST routes

RouteMethodUsed byAccessComplete reference
/wp-json/wgcr/v1/searchGETLive Search widget, [wgcr_search]Public (no login, no nonce)The search REST endpoint

The Comments and FAQ widgets have no REST route. See Features that use no REST below.

Rules they share

  • Namespace: every WidgetCore route lives under wgcr/v1. The full address is https://example.com/wp-json/wgcr/v1/<route>; without pretty permalinks, use https://example.com/?rest_route=/wgcr/v1/<route>.
  • Read only: the routes answer GET and return JSON. Nothing is written to the database, no option, cookie or meta is created.
  • Public data only: results contain only what any visitor can already reach, such as published posts without a password. Custom filters on your site can change this, so keep them safe.
  • Errors follow WordPress: a failed request returns the standard REST error object with code, message and data.status.
  • No rate limiting: the plugin adds none. See the optimisation table in the search reference.
  • Caching: a REST cache must vary by the complete query string and keep the pagination headers.

Features that use no REST

FeatureHow it works instead
Comments widget and [wgcr_comments]The form posts to WordPress' own wp-comments-post.php. Validation, spam checks and moderation are done by WordPress. The plugin adds no REST, AJAX or admin-post handler.
FAQ widgetThe page is rendered on the server. It makes no request after loading.

Check that the REST API works

bash
curl -s "https://example.com/wp-json/wgcr/v1/search?q=test"

A JSON array means the route works. If you get rest_cannot_access, a 404 or an error page, a security plugin, a server rule or the permalink settings are blocking the WordPress REST API; see Troubleshooting and Requirements.