REST API & Developer snippets

Endpoints, cron, debugging and developer tools for building on top of WordPress.

Showing 18 snippets

REST API & Developer PHP Allow More Than 100 Items per REST Request Raise the REST API's 100-item limit for one post type, so a script or app can fetch more items in a single request. Intermediate WP 7.1 REST API & Developer PHP Only Allow REST API Requests From Your Own Domains Replace WordPress's "any origin" CORS headers with a list of domains allowed to call your REST API from a browser. Advanced WP 7.1 REST API & Developer PHP Let Browsers and CDNs Cache Public REST Responses Add Cache-Control headers to public, logged-out REST API GET requests, so headless sites and CDNs can cache them for a few minutes. Intermediate WP 7.1 REST API & Developer PHP Log Errors to a Private File Turn on WordPress debug logging, hide errors from visitors and write the log to a folder that can't be opened in a browser. Intermediate WP 7.1 REST API & Developer PHP Log Slow Database Queries Write any database query that takes longer than 50 ms to the PHP error log, with the function that ran it. Advanced WP 7.1 REST API & Developer PHP Add a Custom Cron Interval and Scheduled Task Add a "Every 15 minutes" schedule to WP-Cron and use it to run your own task in the background. Intermediate WP 7.1
Want it without code?Our plugins do the heavy lifting, with settings, updates and support.
Browse plugins
REST API & Developer PHP List Scheduled Cron Events Under Tools Add a read-only Tools > Cron Events page that lists every scheduled WP-Cron task, when it runs next and how often. Intermediate WP 7.1 REST API & Developer PHP Add Your Own Site Health Check Add a test to Tools > Site Health that warns when plugins your site depends on, like backups or security, are not active. Intermediate WP 7.1 REST API & Developer PHP Add Your Own Section to Site Health Info Add a "Site setup" section to Tools > Site Health > Info with details you want in every support report. Beginner WP 7.1 REST API & Developer PHP Add a Custom WP-CLI Command Create your own wp command, like wp nahnu cleanup, to run site maintenance tasks from the terminal. Intermediate WP 7.1 REST API & Developer PHP Register and Use a Custom Query Variable Let WordPress recognise your own URL parameter, like ?ref=partner, and read it safely anywhere with get_query_var(). Intermediate WP 7.1 REST API & Developer PHP Add a Custom URL Endpoint to Posts Add /print/ to the end of any post URL to show a clean, printer-friendly version, using a WordPress rewrite endpoint. Advanced WP 7.1 REST API & Developer PHP Show Current Template Filename in the Admin Bar Display the name of the PHP template file being used to render each page in the WordPress admin bar, making it instant to identify which template file to edit. Beginner WP 7.1 REST API & Developer PHP Handle an AJAX Request Securely A complete, safe pattern for an admin-ajax.php request: a nonce, a capability check, cleaned input and a JSON response. Intermediate WP 7.1 REST API & Developer PHP Display Query Count and Load Time in the Footer Show the number of database queries and total page load time in the front-end footer for administrators, giving instant performance feedback during development. Beginner WP 7.1 REST API & Developer PHP Set the Environment Type for Staging Sites Tell WordPress and plugins whether a site is production, staging, development or local, so they can behave differently. Beginner WP 7.1 REST API & Developer PHP Add the Featured Image URL to the REST API Add a featured_image_url field to posts in the REST API, so apps and headless front ends don't need a second request for the image. Beginner WP 7.1 REST API & Developer PHP Make a Custom Field Available in the REST API Register a post meta field so it can be read and saved through the REST API and used by block editor sidebars. Intermediate WP 7.1

This website uses cookies to enhance your browsing experience and ensure the site functions properly. By continuing to use this site, you acknowledge and accept our use of cookies.

Accept All Accept Required Only