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

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.

#branding#colors#design
PHPPro

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#location#pro
PHPPro

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#loop#portfolio
PHPPro

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.

#admin#customization#editor
PHPPro

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.

#admin#debugging#deliverability
PHP

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.

#admin#cleanup#notifications
PHPPro

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.

#email#notifications#orders
PHP

Customize WooCommerce Email Footer Text

Replaces the default WooCommerce email footer text with your brand name and site URL using a simple filter.

#branding#email#footer
PHP

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.

#accessibility#mobile#responsive
PHP

Remove Default Author Contact Method Fields

Removes the legacy AIM, Yahoo IM, and Jabber/XMPP contact method rows from the WordPress user profile screen.

#admin#cleanup#contact-methods
PHPPro

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.

#admin#custom-fields#profile
PHP

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.

#admin#contact-fields#profile
PHP

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.

#display-name#privacy#registration
PHP

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.

#login#redirect#registration
PHPPro

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.

#json-ld#rich-snippets#schema
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