25% off ProSNIPC25OFF

Snippet library

WordPress code snippets, ready to use.

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

PHPPro

Add WooCommerce Product Schema Markup

Outputs a JSON-LD Product and Offer schema block in the page head for WooCommerce single product pages, enabling Google rich results.

#json-ld#rich-snippets#schema
PHPPro

Noindex Tag and Category Archives

Outputs a noindex meta robots tag on tag and category archive pages to prevent thin archive content from diluting crawl budget.

#archives#crawl-budget#meta-robots
PHP

Redirect Attachment Pages to Their Parent Post

Permanently redirects WordPress attachment pages to their parent post, preventing thin content pages from accumulating in search indexes.

#301#attachments#redirect
PHP

Customize robots.txt Output

Overrides the virtual WordPress robots.txt via filter to add custom Disallow rules, a Sitemap declaration, and crawl-delay directives.

#crawling#indexing#robots-txt
PHP

Exclude Specific Posts or Pages from the XML Sitemap

Removes a configurable list of post IDs from the WordPress core XML sitemap to prevent thin content from being indexed.

#crawling#indexing#seo
PHPPro

Simple 301 Redirect Manager (Array-Based)

Performs 301 redirects defined in a PHP array, letting you manage URL migrations entirely in code without a plugin.

#301#migrations#redirects
PHPPro

Basic SEO Title and Meta Description Meta Box

Adds a plugin-free SEO Settings meta box to all public post types for entering a custom title and meta description tag.

#meta-box#meta-description#search-engine
PHPPro

Rate-Limit Login Attempts with Transients

Locks out an IP address for 10 minutes after 5 failed login attempts using transients, with automatic unlock on successful login.

#brute-force#hardening#login
PHPPro

Disable WooCommerce Scripts on Non-WooCommerce Pages

Dequeues WooCommerce styles and scripts on pages that are not WooCommerce shop, cart, checkout, or account pages.

#frontend#performance#scripts
PHPPro

Selective Heartbeat API Control

Disables the Heartbeat API everywhere except the post editor, and reduces its interval to 30 seconds on edit screens to minimise AJAX overhead.

#admin#heartbeat#performance
PHPPro

Lazy-Load Iframes in Post Content

Adds the loading="lazy" attribute to all iframe tags found in post content and widget text to defer off-screen iframe loading.

#frontend#iframes#lazy-load
PHPPro

Add DNS Preconnect Hints for External Resources

Outputs preconnect and dns-prefetch link tags in the head for commonly used external domains to reduce connection latency.

#dns-prefetch#frontend#performance
PHPPro

Remove Google Fonts Enqueue from Theme

Dequeues Google Fonts stylesheets registered by popular themes and catches any remaining enqueue whose src points to fonts.googleapis.com.

#fonts#frontend#google-fonts
PHPPro

Defer Non-Critical JavaScript

Adds the defer attribute to all non-critical frontend script tags, skipping jQuery and scripts that already carry async.

#defer#frontend#javascript
PHPPro

Disable Theme and Plugin File Editors

Hides the theme and plugin file editor menu items and redirects direct access attempts to prevent in-browser code editing.

#admin#file-editor#hardening
PHPPro

Add HSTS and Content Security Policy Headers

Sends HTTP Strict Transport Security and a Content-Security-Policy header on HTTPS responses to enforce secure resource loading.

#csp#headers#hsts
PHPPro

Send Basic Security Headers

Adds X-Frame-Options, X-Content-Type-Options, X-XSS-Protection, Referrer-Policy, and Permissions-Policy headers to all frontend responses.

#hardening#headers#http
PHPPro

Restrict REST API to Authenticated Users

Returns a 401 WP_Error for all unauthenticated REST API requests, blocking public access to the entire REST API.

#authentication#hardening#rest-api
PHPPro

Block REST API User Enumeration

Removes the /wp/v2/users REST endpoints for unauthenticated requests to prevent public user account listing.

#hardening#rest-api#security
PHP

Reduce Heartbeat API Frequency

Increases the WordPress Heartbeat API polling interval to 60 seconds site-wide to lower AJAX request load on the server.

#ajax#heartbeat#performance
PHP

Disable WordPress Embeds

Removes oEmbed discovery links, deregisters wp-embed.min.js, and disables embed rewrite rules to prevent the site from being embedded via the WP oEmbed provider.

#embed#oembed#performance
PHP

Limit Post Revisions

Caps stored revisions per post to five to prevent unlimited revision growth in the database.

#cleanup#database#performance
PHP

Disable jQuery Migrate

Removes the jquery-migrate script dependency from the jQuery registration to reduce frontend JavaScript payload.

#frontend#javascript#jquery
PHP

Dequeue Block Library CSS on Frontend

Removes the Gutenberg block library stylesheet on the frontend for themes that do not use core block styles.

#blocks#css#gutenberg