Skip to content

Enabling the REST API in WordPress

The WordPress REST API allows developers to interact with WordPress data (posts, pages, users, etc.) using JSON endpoints. This makes it possible to build apps, integrate external services, or create headless WordPress sites. On ruachost.com, the REST API is enabled by default, but you may need to configure or troubleshoot it.

  • Provides programmatic access to WordPress content.
  • Enables integration with mobile apps or external platforms.
  • Useful for building headless WordPress sites.
  • Allows developers to automate tasks and workflows.
  • Visit the following endpoint in your browser:

    https://yourdomain.com/wp-json/
  • If enabled, you will see a JSON response with site data.

2. Enable REST API via functions.php (if disabled)

Section titled “2. Enable REST API via functions.php (if disabled)”

If your theme or a plugin has disabled the REST API, you can re‑enable it:

// Re-enable WordPress REST API
add_filter('rest_enabled', '__return_true');
add_filter('rest_jsonp_enabled', '__return_true');

Add this snippet to your theme’s functions.php file.

  • Go to Settings → Permalinks.
  • Select a structure other than “Plain” (e.g., Post name).
  • Save changes → This ensures REST API endpoints work correctly.
  • Some security plugins disable the REST API.
  • Temporarily deactivate plugins to identify conflicts.
  • Re‑enable REST API in plugin settings if available.
  • REST API is enabled by default in WordPress 4.7 and later.
  • If you disable it for security reasons, certain features (like Gutenberg editor) may break.
  • Always test API endpoints after enabling.
  • Use authentication (e.g., Application Passwords or OAuth) for secure access.