Snippet library
PHP snippets for WordPress.
467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
Formatted Date and Time Shortcode
Shortcode [current_date] outputs the current date/time in the site's timezone using any PHP date format.
Display a Custom Field Value via Shortcode
Shortcode [custom_field key="field_name"] outputs the value of any post meta field inline.
Auto-Link Keywords to Internal Pages
Automatically hyperlinks the first occurrence of configured keywords to their target URLs in post content.
Auto-Insert Affiliate Disclosure on Posts
Prepends a compliance disclosure notice to any post tagged with the 'affiliate' tag.
Add Anchor Links to Headings Automatically
Adds a clickable # anchor link beside every h2–h4 heading in post content for easy linking.
Auto-Generate Excerpt from Post Content
Generates a trimmed excerpt from the post body when no manual excerpt has been written.
Show Post Count in Category and Tag Titles
Appends the post count in parentheses to category, tag, and custom taxonomy archive titles.
Display Archive and Term Description on Archives
Outputs the term or author description block above the post list on archive pages.
Exclude a Category from the Blog Homepage Loop
Removes a specified category from the main blog and front-page feed using pre_get_posts.
Insert Content After the Last Paragraph
Injects a configurable CTA block immediately after the last paragraph on single posts.
Show Featured Image in Archive Post Lists
Prepends the post thumbnail to excerpts on archive, category, tag, and search results pages.
Show Both Published and Modified Dates
Appends both the original publish date and the last-modified date below single-post content.
Expose Nav Menus via the REST API
Registers a GET /wp-json/scseed/v1/menu?location=primary endpoint that returns the items of a registered navigation menu.
Add a Custom Field to the Users REST Response
Exposes a custom user meta field (job_title) in the WP REST API users endpoint with read and write support.
Meta Pixel WooCommerce Events (AddToCart/Purchase)
Fires Meta Pixel AddToCart (on AJAX add) and Purchase (on order confirmation) events for WooCommerce.
WooCommerce GA4 Add-to-Cart and Checkout Events
Fires GA4 add_to_cart and begin_checkout ecommerce events via server-injected scripts; requires gtag.js on the page.
Google Consent Mode v2 Default Settings
Sets Google Consent Mode v2 default states before any tags fire, denying ad and analytics storage until consent is granted.
Change the Place Order Button Text
Replaces the default 'Place order' label on the WooCommerce checkout submit button with a custom string.
Bulk Delete Orders Tool
Adds a 'Delete Permanently' bulk action to the WooCommerce admin orders screen, supporting both legacy post-based and HPOS order storage.
Add an Empty Cart Button
Adds a nonce-protected 'Empty Cart' button to the WooCommerce cart page so customers can clear all items in one click.
Add a Custom Product Information Tab
Appends an extra 'More Information' tab to the WooCommerce single-product tab row, populated from a custom product meta field.
Hide Specific Categories from the Shop Loop
Excludes one or more product category slugs from the WooCommerce shop, archive, and search loops while keeping individual category pages accessible.
Add a Products Column to the Admin Orders List
Inserts a 'Products' column into the WooCommerce orders list screen showing each order's item names and quantities at a glance.
Register a Custom Flat-Rate Shipping Method
Defines a code-based WooCommerce shipping method with a configurable title and fixed cost, assignable to shipping zones.