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.

PHPPro

WooCommerce GA4 Purchase Event

Sends a GA4 Measurement Protocol purchase event server-side when a WooCommerce order status changes to completed, capturing transaction ID, revenue, tax, shipping, and line items.

#analytics#ecommerce#ga4
PHP

SEO Breadcrumbs Shortcode

Registers a [scseed_breadcrumbs] shortcode that renders a semantic nav breadcrumb trail with home link, optional category, and current page — no plugin required.

#breadcrumbs#frontend#navigation
PHP

Insert Header and Footer Code

Provides two configurable injection points — wp_head and wp_footer — so you can paste any scripts or markup into every page without editing theme files.

#customization#footer#head
PHP

Add Custom Meta Tag to Head

Outputs one or more custom name or property meta tags into the page head; edit the array to add or remove tags without touching theme files.

#custom#head#html
PHP

Add Site Verification Meta Tags

Adds Google Search Console, Bing Webmaster Tools, Yandex, and Pinterest domain verification meta tags to every page head; leave any value empty to skip that provider.

#google#meta#seo
PHPPro

Add hreflang Tags for Translations

Outputs hreflang alternate link tags for multilingual sites using WPML or Polylang, with a single-language self-referencing fallback when neither plugin is active.

#hreflang#international#meta
PHPPro

Set Meta Description from Excerpt

Automatically outputs a meta description tag using the post excerpt, or falls back to a trimmed plaintext snippet from the post content on singular pages.

#description#excerpt#frontend
PHP

Noindex Specific Pages by ID

Adds a noindex,follow robots meta tag to specific pages or posts identified by their numeric ID, without touching any other URLs.

#meta#noindex#pages
PHPPro

Noindex Search, Author, Paginated

Adds a noindex,follow robots meta tag to search results, author archives, and paginated non-singular pages to prevent thin-content indexing.

#meta#noindex#robots
PHPPro

Set Canonical Ignoring Query Strings

Replaces WordPress's default canonical link with a query-string-stripped version so paginated/filtered URLs don't compete for indexing.

#canonical#meta#seo
PHPPro

Add Author/Person Schema

Outputs a Person schema.org JSON-LD block on author archive pages with name, URL, bio, and optional Twitter/social sameAs link for author entity markup.

#author#json-ld#schema
PHPPro

Auto-Generate BreadcrumbList JSON-LD

Automatically builds and outputs a BreadcrumbList schema.org JSON-LD block on single posts, category archives, and taxonomy pages for Google breadcrumb rich results.

#breadcrumbs#json-ld#navigation
PHPPro

Add LocalBusiness Schema

Injects a LocalBusiness schema.org JSON-LD block on the homepage with your business name, address, geo-coordinates, hours, phone, and price range.

#json-ld#local-seo#schema
PHPPro

Add WebSite Schema with Search Box

Outputs a WebSite schema.org JSON-LD block with a SearchAction sitelinks searchbox so Google can surface a search field directly in results.

#json-ld#schema#search-box
PHPPro

Add Organization Schema JSON-LD

Outputs an Organization schema.org JSON-LD block on the homepage with your site name, URL, logo, contact details, and social profile links.

#json-ld#organization#schema
PHPPro

Add Article Schema JSON-LD

Injects an Article schema.org JSON-LD block into single post pages with headline, description, dates, author, and featured image for Google rich results.

#json-ld#posts#schema
PHPPro

Add Twitter Card Meta Tags

Outputs twitter:card, twitter:title, twitter:description, and twitter:image meta tags on singular posts so X/Twitter renders rich preview cards.

#frontend#meta#seo
PHPPro

Add Open Graph Meta Tags

Outputs og:type, og:title, og:description, og:url, og:site_name, and og:image meta tags for singular posts and the homepage to enable rich social link previews.

#frontend#meta#open-graph
PHPPro

Conditionally Remove jQuery Frontend

Dequeues jQuery and jquery-migrate on the frontend on simple page types where no enqueued scripts depend on it, reducing page weight.

#javascript#jquery#optimization
PHP

Disable Block Directory Requests

Removes the block directory feature from the block editor, preventing outbound HTTP requests to the WordPress.org block directory while editing.

#admin#blocks#editor
PHP

Change Trash Auto-Empty Days

Overrides the number of days WordPress waits before permanently deleting trashed posts (default is 30 days).

#admin#cleanup#maintenance
PHP

Disable Core WordPress Sitemaps

Turns off the built-in WordPress XML sitemap feature when an SEO plugin already generates its own sitemap.

#optimization#performance#seo
PHPPro

Prevent Loading Translation Files

Blocks specified plugins from loading their .mo translation files when the site locale is English, eliminating unnecessary disk reads.

#i18n#optimization#performance
PHPPro

Defer or Async Scripts by Handle

Adds defer or async attributes to specific registered script handles so they do not block HTML parsing.

#async#defer#javascript