Snippet library
PHP snippets for WordPress.
467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
Change Cart and Checkout Thumbnail Size
Overrides the WooCommerce cart and checkout line-item product thumbnail dimensions to a custom width and height.
Move Shop Category Description Below Products
Removes the WooCommerce archive description from above the product grid and re-inserts it below the loop so products appear first.
Redirect to a Custom Page After Checkout
Sends customers to a custom thank-you or upsell page after completing a WooCommerce order instead of the default order-received endpoint.
Require Purchase to Leave a Product Review
Restricts WooCommerce product reviews to verified buyers only — the review form is hidden and the comment is blocked for non-purchasers.
Set Out-of-Stock Products to Draft Automatically
Watches WooCommerce stock updates and automatically switches any product to Draft status the moment its stock quantity reaches zero.
Sort Out-of-Stock Products Last in Catalog
Pushes out-of-stock WooCommerce products to the end of shop and archive loops while preserving the existing sort order for in-stock items.
Show Amount Saved on Sale Products
Appends a 'You save $X (Y%)' message after the price on WooCommerce sale products, showing both the absolute and percentage discount.
Hide Sale Badges Across the Store
Removes the 'Sale!' flash badge from all WooCommerce product cards and single product pages by returning an empty string.
Set Minimum Order Quantity per Product
Reads a per-product minimum quantity meta value and enforces it on the quantity input and at add-to-cart validation.
Enforce Minimum and Maximum Product Price
Validates a WooCommerce product's regular price against configurable min/max bounds on admin save and surfaces an error notice if violated.
Change WooCommerce Currency Symbol or Format
Overrides the WooCommerce currency symbol, price display format, decimal separator, and thousands separator via filters.
Replace Add to Cart with a Call-to-Order Button
Disables the add-to-cart button on opted-in products and replaces it with a phone or enquiry CTA drawn from product meta.
Change a User's Role After Purchase
Automatically upgrades or assigns a WordPress role to a customer when they complete an order containing a specific product.
Prevent Repeat Purchase of a Product
Blocks customers from adding or purchasing a product they have already bought in a completed or processing order.
Add Total Word Count to the Publish Box
Displays the post's word count inside the Classic Editor's Publish meta box and keeps it updated live in the Block Editor.
Strip the Admin Bar to Essential Items
Removes all non-essential admin bar nodes for non-administrator users, leaving only the site name and user account links.
Sort Admin Post List Alphabetically by Title
Sets the default ordering of the Posts list table in wp-admin to A-Z by title when no custom sort column is active.
Enqueue a Custom Admin Stylesheet
Loads a custom CSS file from the active theme into every wp-admin screen, allowing targeted overrides of WordPress admin styles.
Disable Email Domain Typo Suggestion
Dequeues the mailcheck library used by WooCommerce and WPForms to suppress the 'Did you mean …?' email-domain correction prompt.
Post Meta Debug Panel for Admins
Adds a meta box to all public post type edit screens that dumps every piece of post meta, visible to administrators only.
Time-Based Greeting in the Admin Bar
Displays a personalised Good morning/afternoon/evening greeting with the current user's display name in the WordPress admin bar.
Collapse the Admin Menu by Default
Sets the admin sidebar to start in its collapsed state for users who have not yet expressed a preference.
Show Staging/Environment Banner in Admin Bar
Adds a coloured environment label (Staging, Development, Local) to the admin bar so users always know they are not on production.
Hide Specific User Roles from the Role Selector
Prevents non-administrator users from assigning powerful roles such as Administrator or Editor when editing a user's profile.