Snippet library
PHP snippets for WordPress.
467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
Elementor: Disable Default Color Palettes
Prevents Elementor from injecting its built-in default color scheme so the site's own global colors remain the sole source of truth.
Elementor: Register Custom Theme Builder Location
Registers a custom Theme Builder template location (hero slot) that Elementor Pro templates can target and render in the theme.
Elementor: Filter Posts Widget Query by Query ID
Modifies the WP_Query for a specific Elementor Posts/Archive widget by matching the Query ID set in the widget Content panel.
Elementor: Register Custom Widget Category
Adds a custom group category to the Elementor widget panel so bespoke widgets can be visually separated from built-in ones.
Add a Send Test Email Admin Tool
Adds a Tools > Test Email page in the WordPress admin where site administrators can send a test email to verify SMTP and mail-server deliverability.
Hide Admin Update Notifications (Keep Emails)
Suppresses core, plugin, and theme update nags in the WordPress dashboard for users who cannot perform updates, while leaving background email alerts intact.
Change WooCommerce Order Email Recipients
Routes WooCommerce new-order, cancelled-order, and failed-order emails to additional recipients defined via a filterable list, including the admin address.
Customize WooCommerce Email Footer Text
Replaces the default WooCommerce email footer text with your brand name and site URL using a simple filter.
Enable Pinch-to-Zoom on Mobile
Replaces any restrictive viewport meta tag (one that sets user-scalable=no or maximum-scale=1) with a permissive one that allows pinch-to-zoom.
Remove Default Author Contact Method Fields
Removes the legacy AIM, Yahoo IM, and Jabber/XMPP contact method rows from the WordPress user profile screen.
Add Custom Profile Fields for Users
Adds arbitrary editable text fields (job title, company, phone) to the WordPress user profile and stores each value as user meta.
Add Social Media Links to User Profiles
Adds Twitter/X, LinkedIn, and GitHub URL fields to the WordPress user profile screen and saves them as user meta.
Set Display Name to Username on Registration
Sets new users' display name to their login username on registration so their real name is not exposed publicly by default.
Redirect Users to the Previous Page After Login
Sends users back to the page they were visiting before the login form, falling back to the default WordPress redirect when no referer exists.
Add VideoObject Schema for Embedded Videos
Detects the first YouTube or Vimeo embed in a singular post and outputs a JSON-LD VideoObject schema block to enable video rich results.
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.