Snippet library
PHP snippets for WordPress.
467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
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.
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.
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.
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.
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.
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: 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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
EDD: Override Store Currency via Filter
Programmatically sets the EDD store currency to a fixed value, overriding whatever currency is selected in EDD settings.
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.
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.
EDD: Disable Guest Checkout
Forces customers to be logged in before completing an EDD purchase, removing the guest checkout option from the checkout page.
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.