Snippet library
PHP snippets for WordPress.
467 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
Add a Custom Bulk Action to Post Lists
Registers a 'Set to Draft' bulk action on the Posts list screen so editors can unpublish many posts at once.
Add a Custom Admin Menu Link
Adds a top-level admin sidebar item that redirects to an external URL such as documentation or a project management tool.
Require a Category Selection Before Publishing
Prevents posts from being published if they remain in only the default Uncategorized category, enforcing deliberate categorization.
Require Minimum Word Count to Publish
Blocks publication of a post until its content reaches a configurable minimum word count (default 300 words).
Require Featured Image Before Publishing
Prevents posts and pages from being published unless a featured image has been set, covering both Block and Classic editors.
Set Default Image Link to None on Insert
Prevents WordPress from automatically wrapping inserted images in anchor tags linking to the attachment page or file.
Set Default Image Insert Size in Editor
Changes the default image size selected when inserting media into a post to 'large'.
Change Editor Autosave Interval
Extends the Block Editor autosave interval to 2 minutes (default is 60 seconds) to reduce unnecessary revision noise.
Disable Openverse Media in Block Editor
Removes the Openverse external image search tab from the Block Editor media panel.
Disable Block Template Editor
Removes the template-editing option from the Block Editor so users cannot modify block templates.
Disable Full Site Editing
Hides the Site Editor menu entry and disables template-editing mode in the Block Editor.
Disable Code Editor in Block Editor for Non-Admins
Locks the HTML/Code editor view in Gutenberg to administrators only, preventing non-admins from switching to raw markup.
Disable Block Editor Welcome Guide Popup
Suppresses the introductory welcome modal that appears the first time a user opens the Block Editor.
Disable Block Editor Fullscreen Mode by Default
Opens the Block Editor in windowed mode instead of fullscreen for all users.
Disable Block Editor Site-Wide (Use Classic Editor)
Forces the Classic Editor for all post types by disabling the Block Editor globally.
Add a Custom User Role
Registers a new WordPress user role with a defined set of capabilities, falling back gracefully if the role already exists.
Hide a Taxonomy From Public and Admin UI
Makes an existing taxonomy internal-only by removing it from the admin menu, REST API, and frontend URLs while keeping the data intact.
Disable Default Categories and Tags Taxonomies
Unregisters the built-in Categories and Tags taxonomies from Posts for sites that use custom taxonomies exclusively.
Remove Posts Post Type From Admin
Hides the Posts menu item and removes Posts from the admin bar for non-admin users on sites that do not use the blog.
Add a Custom Meta Box and Save Field
Registers a meta box on the post edit screen with a sanitized text field that is saved and retrieved via the WordPress meta API.
Include a CPT in the Main Blog Loop
Merges a custom post type into the main blog archive and home feed query so its posts appear alongside standard posts.
Make a CPT Sortable by Drag and Drop
Adds jQuery UI sortable drag-and-drop ordering to a custom post type list table and saves the manual order to post_menu_order.
Add Featured Image Support to All Post Types
Enables thumbnail (featured image) support on every registered public custom post type that does not already have it.
Add Excerpt Support to Pages
Enables the Excerpt meta box on Pages so editors can write custom page descriptions used by themes and SEO plugins.