Cookbook
Each recipe solves one problem with as few files as possible, committed and pushed like the rest of your project. The recipes built on a Composer package come in three shapes:
- most recipes are a Custom API Route, one PHP file pushed with
lps api push; - a few are a snippet, when the code reacts to a WordPress event instead of answering a URL, pushed with
lps snippet push; - one pairs hooks with a single-page app, pushed with
lps hook pushandlps app push.
Every recipe states which kind it is at the top. The Site as Code recipes need no Composer package: they build a feature from several Loopress resources, such as a post type, a taxonomy, post meta and a route, pushed together with lps push.
The other recipes rely on Composer dependency management, a Loopress Full feature, to install their package on the site. If verb methods, permission(), Composer autoloading or failure isolation are new to you, start with Writing Route Files, in particular using your own Composer dependencies.
Browse by category below or in the sidebar.
Documents & Files
- Exporting WooCommerce Orders to XLSX with PhpSpreadsheet
A Custom API Route that exports completed WooCommerce orders to a downloadable Excel .xlsx file with PhpSpreadsheet, for the client who wants the numbers.
- iCal Calendar Feed for WordPress Events with eluceo/ical
Serve your WordPress events as a live .ics calendar feed with eluceo/ical and a Custom API Route, so visitors subscribe once in Google or Apple Calendar.
- Import a CSV into WordPress with a REST Route and League CSV
Upload a supplier CSV to a WordPress REST route that parses it with league/csv, creates draft products and reports every rejected row, editors only.
- Rendering a WordPress Post as a Downloadable PDF
A Custom API Route that turns any published post's rendered content into a PDF on request, using dompdf, for a "Download as PDF" button that doesn't need a plugin.
- Ticket QR Code Generation in a WordPress REST API Route
A Custom API Route renders a scannable QR code for an event ticket on request with endroid/qr-code, so no image file is stored per ticket sold or goes stale.
Content & Data
- Headless WordPress Sitemap for a Next.js or Astro Frontend
A Custom API Route that returns an XML sitemap with your frontend's own domain, built from WordPress posts and pages, since wp-sitemap.xml lists the CMS origin.
- Serve WordPress Posts as Markdown for LLMs and AI Search
Add a public WordPress REST route that returns any published post as clean Markdown with league/html-to-markdown, ready for llms.txt, AI crawlers and RAG.
Search & Data Services
- Query ACF Fields with GraphQL, in Your Own API Route
A Custom API Route that answers GraphQL queries against ACF fields deployed by Loopress, using webonyx/graphql-php, without installing a full GraphQL plugin.
- Typo-Tolerant Instant Search in WooCommerce with Algolia
Index a WooCommerce catalog into Algolia with a Hook, then replace the native search box with a typo-tolerant React app using the Algolia PHP and JS clients.
Auth & Security
- Headless WordPress Draft Preview with Signed JWT Links
Preview unpublished WordPress drafts on a Next.js or Astro frontend with short-lived signed JWT links and two REST routes, no admin password shared.
- Verify Stripe Webhook Signatures in a WordPress REST Route
Receive Stripe webhooks in WordPress and verify the Stripe-Signature header with stripe-php's constructEvent in one Loopress API route. No account needed.
Site as Code
- Undo a Bad WordPress Deploy: lps diff and Rollback
See what a client changed in wp-admin before you push over it, and undo a bad push with lps rollback. The whole safety net, shown on a nav menu.
- Upcoming Events in WordPress: Custom Post Type and REST API
Build a WordPress events catalog in Git: an event post type, an event type taxonomy, date and venue meta, and a REST route listing upcoming events by date.
- WordPress Client Editor Role in Git: Safe Custom Role
Give a client a WordPress role that can write and publish but not touch plugins, themes or settings, declared as a JSON file in Git with lps role push.
- WordPress Landing Page in Git: Pattern and Theme Styles
Ship a WordPress landing page from your repository: a static HTML page, a block pattern for the hero and Global Styles for colors and fonts, pushed with lps.