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

Yoast SEO: Remove the Admin Bar Node

Removes the Yoast SEO traffic-light node from the WordPress admin bar on both the frontend and back end.

#admin-bar#cleanup#seo
PHP

Yoast SEO: Remove SEO and Readability Columns from Post Lists

Removes the Yoast SEO score, readability score, SEO title, meta description, and focus keyword columns from all post-type list tables in the admin.

#admin#cleanup#columns
PHP

Yoast SEO: Lower the Metabox Priority

Moves the Yoast SEO metabox lower on the post-edit screen by setting its priority to low, so it does not crowd the top of the editor sidebar.

#admin#editor#metabox
PHP

Yoast SEO: Remove HTML Debug Comment Markers

Hides the Yoast SEO HTML comment markers (<!-- This site is optimized with the Yoast SEO plugin -->) from page source output.

#cleanup#html-comments#performance
PHP

Contact Form 7: Load Scripts and Styles Only on Form Pages

Dequeues the Contact Form 7 CSS and JavaScript on every page that does not contain a CF7 shortcode, reducing unnecessary asset loading across the site.

#assets#contact-form-7#enqueue
PHPPro

Contact Form 7: Minimum Word Count Validation for Textarea

Adds a minwords:N tag option to CF7 textarea fields that rejects submissions containing fewer than N words, with a localised error message displayed inline.

#contact-form-7#forms#textarea
PHP

Contact Form 7: Disable Automatic Paragraph Tags in Form Markup

Prevents Contact Form 7 from passing form content through wpautop and wptexturize, stopping unwanted <br> and <p> tags from being injected into the form HTML.

#autop#contact-form-7#formatting
PHP

WPForms: Customize Inline Validation Error Messages

Replaces the default WPForms frontend validation messages (required field, invalid email, etc.) with custom branded copy, via the wpforms_frontend_strings filter.

#error-messages#forms#ux
PHP

WPForms: Change Submit Button and Processing Text

Customizes the WPForms submit button label and the "sending" processing text shown while the form submits, via the wpforms_frontend_form_data filter.

#customization#forms#submit-button
PHP

WPForms: Restrict Form to Logged-In Users Only

Intercepts the WPForms shortcode and replaces the form with a login prompt for visitors who are not authenticated, using the WordPress pre_do_shortcode_tag filter.

#access-control#forms#login
PHPPro

WPForms: Restrict File Upload Field to Specific Extensions

Adds an HTML accept attribute to WPForms file-upload field inputs to guide browsers toward the allowed file types, using the wpforms_field_properties filter.

#extensions#file-upload#forms
PHPPro

WPForms: Register and Process a Custom Smart Tag

Adds a {user_registered_date} Smart Tag to WPForms that outputs the current logged-in user's registration date in email notifications and confirmations.

#forms#notifications#smart-tags
PHP

Gravity Forms: Limit Total Form Entries

Blocks new submissions once a Gravity Forms form reaches a configurable maximum entry count and shows the user a friendly closed-form message.

#entry-limit#form-management#forms
PHPPro

Gravity Forms: Conditional Confirmation Redirect by Field Value

Redirects users to different thank-you pages after form submission based on the value of a specific field (e.g. a Plan selector), using the gform_confirmation filter.

#conditional-logic#confirmation#forms
PHPPro

Gravity Forms: Populate Dropdown Choices from WordPress Categories

Dynamically fills a Gravity Forms Select field (identified by a CSS class) with the current WordPress post categories, keeping choices in sync without manual updates.

#categories#dropdown#dynamic-choices
PHPPro

Gravity Forms: Server-Side Custom Field Validation

Adds a custom server-side validation rule to a specific Gravity Forms field — this example enforces a UK postcode format on a configurable form and field ID.

#custom-validation#forms#gravity-forms
PHP

Gravity Forms: Customize the Submit Button HTML

Replaces the default Gravity Forms submit input with a styled button element including custom text, using the gform_submit_button filter.

#customization#forms#gravity-forms
PHPPro

Gravity Forms: Pre-Populate Field from URL Query Parameter

Uses the gform_field_value_{parameter} filter to pre-fill a Gravity Forms field with a value passed in the page URL, such as a UTM source or referral code.

#dynamic-fields#forms#gravity-forms
PHPPro

EDD: Display Customer Purchase Count in Admin Users List

Adds an "EDD Purchases" column to the WordPress admin Users list table showing each user's total EDD purchase count, linked to their EDD customer record.

#admin#customers#edd
PHP

EDD: Override Store Currency via Filter

Programmatically sets the EDD store currency to a fixed value, overriding whatever currency is selected in EDD settings.

#currency#edd#localization
PHPPro

EDD: Register Custom Email Tag for Customer Purchase Count

Adds an {edd_customer_purchase_count} email tag that inserts the customer's total completed purchase count into EDD notification emails.

#automation#customers#edd
PHPPro

EDD: Restrict Content to Download Purchasers Shortcode

Adds a [scseed_edd_purchasers_only id="123"] shortcode that shows enclosed content only to logged-in users who have purchased a specific EDD download.

#access-control#content-restriction#edd
PHP

EDD: Disable Guest Checkout

Forces customers to be logged in before completing an EDD purchase, removing the guest checkout option from the checkout page.

#checkout#edd#guest
PHP

EDD: Empty Cart Link Shortcode

Registers a [scseed_edd_empty_cart] shortcode that outputs a link customers can click to clear their entire EDD shopping cart.

#cart#edd#frontend