WordPress Archive Query — pre_get_posts Control PHP
A focused pre_get_posts helper for changing archive page sizes per post type without touching admin screens, secondary queries, or unrelated blog archives.
Practical, copy-ready snippets from real WordPress, WooCommerce and frontend projects — written to drop straight into a theme, child theme or component.
A focused pre_get_posts helper for changing archive page sizes per post type without touching admin screens, secondary queries, or unrelated blog archives.
A clean, well-commented boilerplate for registering custom post types in WordPress — with proper labels, REST API support, archive configuration, and filter hooks for child theme overrides.
Defer non-critical WordPress scripts (contact forms, sliders, analytics) without breaking jQuery dependencies — using wp_script_add_data, conditional loading, and WordPress filter hooks. No plugin needed.
Display a product badge (New, Sale, Sold Out, Made in ___) based on product tags, metafields, or inventory status — one Liquid snippet, consistent across collection pages and…
Add quantity increment/decrement buttons to the Shopify cart drawer with AJAX updates — no page reload, optimistic UI, and proper error handling using the Shopify AJAX API.
A reusable Liquid snippet that safely renders Shopify product metafields with type detection, fallback handling, and null safety — one include, every metafield on the site.
Display a "Sale" badge with the actual percentage discount on WooCommerce product cards — using product price comparison, simple math, and WooCommerce action hooks. No template overrides needed.
Display a notice on the WooCommerce checkout page when the cart total meets a threshold — free shipping eligibility, bulk discount qualification, or minimum order requirements — using…
Add a custom field to the WooCommerce checkout form with server-side validation, order meta storage, and admin display — using WordPress filter hooks, not template overrides.