Snippet library
WordPress code snippets, ready to use.
707 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
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.
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.
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.
Customize robots.txt Output
Overrides the virtual WordPress robots.txt via filter to add custom Disallow rules, a Sitemap declaration, and crawl-delay directives.
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.
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.
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.
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.
Disable WooCommerce Scripts on Non-WooCommerce Pages
Dequeues WooCommerce styles and scripts on pages that are not WooCommerce shop, cart, checkout, or account pages.
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.
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.
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.
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.
Defer Non-Critical JavaScript
Adds the defer attribute to all non-critical frontend script tags, skipping jQuery and scripts that already carry async.
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.
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.
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.
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.
Block REST API User Enumeration
Removes the /wp/v2/users REST endpoints for unauthenticated requests to prevent public user account listing.
Reduce Heartbeat API Frequency
Increases the WordPress Heartbeat API polling interval to 60 seconds site-wide to lower AJAX request load on the server.
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.
Limit Post Revisions
Caps stored revisions per post to five to prevent unlimited revision growth in the database.
Disable jQuery Migrate
Removes the jquery-migrate script dependency from the jQuery registration to reduce frontend JavaScript payload.
Dequeue Block Library CSS on Frontend
Removes the Gutenberg block library stylesheet on the frontend for themes that do not use core block styles.