Cookbook
Each recipe solves one problem with one Composer package and as few files as possible, committed and pushed like the rest of your project:
- 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. They all 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 turns a WooCommerce orders query into a downloadable Excel file, using PhpSpreadsheet, for the client who just wants "the numbers in a spreadsheet."
- Generating a Ticket QR Code from a WordPress Route with Endroid QR Code
A Custom API Route that renders a scannable QR code for an event ticket on request, using endroid/qr-code, instead of generating and storing an image file per ticket sold.
- 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.
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 query it straight from a React single-page app using algolia/algoliasearch-client-php and the official Algolia JS client.