25% off ProSNIPC25OFF

Snippet library

WordPress code snippets, ready to use.

707 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.

PHPPro

Add Open Graph Meta Tags

Outputs og:type, og:title, og:description, og:url, og:site_name, and og:image meta tags for singular posts and the homepage to enable rich social link previews.

#frontend#meta#open-graph
CSS

Respect prefers-reduced-motion

Disables CSS animations and transitions for users who have enabled the reduce-motion accessibility setting in their operating system.

#accessibility#animation#css
CSSPro

CSS-Only Hamburger Toggle

A fully CSS-driven hamburger menu toggle using a hidden checkbox and sibling selectors — no JavaScript required.

#css#hamburger#mobile
CSS

Aspect-Ratio Media Wrapper

CSS utilities for maintaining consistent aspect ratios on images, videos, and iframes using the native aspect-ratio property.

#css#layout#media
CSSPro

Fluid Typography With clamp()

Scales heading and body font sizes smoothly across all viewport widths using CSS clamp(), eliminating hard breakpoint jumps.

#css#fluid#responsive
CSS

Mobile/Desktop Visibility Classes

Provides utility classes to show or hide elements at mobile, tablet, and desktop breakpoints without any JavaScript.

#css#layout#responsive
CSSPro

Sticky Sidebar on Scroll

Pins the sidebar to the viewport as the user scrolls using CSS position: sticky, with a configurable offset for fixed headers.

#css#layout#sidebar
CSSPro

Responsive Stacking Tables on Mobile

Makes wide HTML tables readable on small screens by collapsing each row into a labelled card layout using data attributes and no JavaScript.

#css#mobile#responsive
CSS

Equal-Height Card Grid

Uses CSS Grid and flexbox to build a responsive card layout where every card in the same row shares the same height with footers pinned to the bottom.

#cards#css#grid
CSSPro

Custom-Styled Checkboxes and Radios

Replaces native checkbox and radio button appearance with fully CSS-styled controls that match brand colours and scale with the font size.

#accessibility#checkboxes#css
CSS

Style Form Placeholder Text

Applies consistent colour and font-style to placeholder text in all form inputs and textareas, with a subtle fade on focus.

#css#forms#placeholder
CSS

Prevent Widows in Headings

Uses CSS text-wrap: balance on headings and text-wrap: pretty on body copy to prevent orphaned single words on the last line.

#accessibility#css#headings
CSS

Modern CSS Reset

A lightweight opinionated CSS reset that normalises browser defaults, enforces border-box sizing, and improves baseline typography across all elements.

#css#layout#reset
PHPPro

Conditionally Remove jQuery Frontend

Dequeues jQuery and jquery-migrate on the frontend on simple page types where no enqueued scripts depend on it, reducing page weight.

#javascript#jquery#optimization
PHP

Disable Block Directory Requests

Removes the block directory feature from the block editor, preventing outbound HTTP requests to the WordPress.org block directory while editing.

#admin#blocks#editor
PHP

Change Trash Auto-Empty Days

Overrides the number of days WordPress waits before permanently deleting trashed posts (default is 30 days).

#admin#cleanup#maintenance
PHP

Disable Core WordPress Sitemaps

Turns off the built-in WordPress XML sitemap feature when an SEO plugin already generates its own sitemap.

#optimization#performance#seo
PHPPro

Prevent Loading Translation Files

Blocks specified plugins from loading their .mo translation files when the site locale is English, eliminating unnecessary disk reads.

#i18n#optimization#performance
PHPPro

Defer or Async Scripts by Handle

Adds defer or async attributes to specific registered script handles so they do not block HTML parsing.

#async#defer#javascript
PHPPro

Dequeue Scripts and Styles by Page

Conditionally dequeues specified CSS and JS handles on pages where they are not needed, reducing per-page asset weight.

#assets#dequeue#optimization
PHPPro

Preload Hero/Featured Image

Outputs a rel='preload' hint for the current post's featured image on singular pages, prioritising its fetch to improve Largest Contentful Paint.

#images#lcp#optimization
CSS

Add font-display swap to Fonts

Provides a @font-face template with font-display: swap so self-hosted fonts use a fallback immediately, eliminating invisible text during load (FOIT).

#css#fonts#optimization
PHPPro

Preload Critical Fonts

Outputs rel='preload' link hints in the document head for self-hosted web-font files so the browser fetches them at the highest priority.

#fonts#optimization#performance
JavaScriptPro

Lazy-Load Background Images

Uses IntersectionObserver to defer loading of CSS background images until the element is about to enter the viewport, reducing initial page weight.

#images#javascript#lazy-load