25% off ProSNIPC25OFF

Snippet library

PHP snippets for WordPress.

467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.

PHP

Formatted Date and Time Shortcode

Shortcode [current_date] outputs the current date/time in the site's timezone using any PHP date format.

#date#display#dynamic
PHP

Display a Custom Field Value via Shortcode

Shortcode [custom_field key="field_name"] outputs the value of any post meta field inline.

#content#custom-field#display
PHPPro

Auto-Link Keywords to Internal Pages

Automatically hyperlinks the first occurrence of configured keywords to their target URLs in post content.

#content#internal-links#keywords
PHPPro

Auto-Insert Affiliate Disclosure on Posts

Prepends a compliance disclosure notice to any post tagged with the 'affiliate' tag.

#affiliate#compliance#content
PHPPro

Add Anchor Links to Headings Automatically

Adds a clickable # anchor link beside every h2–h4 heading in post content for easy linking.

#anchor#content#headings
PHP

Auto-Generate Excerpt from Post Content

Generates a trimmed excerpt from the post body when no manual excerpt has been written.

#auto#content#display
PHP

Show Post Count in Category and Tag Titles

Appends the post count in parentheses to category, tag, and custom taxonomy archive titles.

#archive#category#display
PHP

Display Archive and Term Description on Archives

Outputs the term or author description block above the post list on archive pages.

#archive#category#description
PHPPro

Exclude a Category from the Blog Homepage Loop

Removes a specified category from the main blog and front-page feed using pre_get_posts.

#category#exclude#homepage
PHPPro

Insert Content After the Last Paragraph

Injects a configurable CTA block immediately after the last paragraph on single posts.

#content#conversion#cta
PHP

Show Featured Image in Archive Post Lists

Prepends the post thumbnail to excerpts on archive, category, tag, and search results pages.

#archive#display#excerpt
PHP

Show Both Published and Modified Dates

Appends both the original publish date and the last-modified date below single-post content.

#content#dates#display
PHPPro

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.

#api#headless#menus
PHPPro

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.

#api#headless#rest-api
PHPPro

Meta Pixel WooCommerce Events (AddToCart/Purchase)

Fires Meta Pixel AddToCart (on AJAX add) and Purchase (on order confirmation) events for WooCommerce.

#ecommerce#facebook#meta
PHPPro

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.

#analytics#ecommerce#events
PHPPro

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.

#analytics#consent#gdpr
PHP

Change the Place Order Button Text

Replaces the default 'Place order' label on the WooCommerce checkout submit button with a custom string.

#buttons#checkout#customization
PHPPro

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.

#admin#bulk-actions#cleanup
PHP

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.

#buttons#cart#frontend
PHP

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.

#customization#display#products
PHPPro

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.

#catalog#categories#filtering
PHPPro

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.

#admin#columns#customization
PHPPro

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.

#admin#checkout#customization