Snippet library
WordPress code snippets, ready to use.
707 free & Pro snippets and modules. Copy-paste-ready, or import in one click with SnipCraft.
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.
Respect prefers-reduced-motion
Disables CSS animations and transitions for users who have enabled the reduce-motion accessibility setting in their operating system.
CSS-Only Hamburger Toggle
A fully CSS-driven hamburger menu toggle using a hidden checkbox and sibling selectors — no JavaScript required.
Aspect-Ratio Media Wrapper
CSS utilities for maintaining consistent aspect ratios on images, videos, and iframes using the native aspect-ratio property.
Fluid Typography With clamp()
Scales heading and body font sizes smoothly across all viewport widths using CSS clamp(), eliminating hard breakpoint jumps.
Mobile/Desktop Visibility Classes
Provides utility classes to show or hide elements at mobile, tablet, and desktop breakpoints without any JavaScript.
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.
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.
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.
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.
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.
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.
Modern CSS Reset
A lightweight opinionated CSS reset that normalises browser defaults, enforces border-box sizing, and improves baseline typography across all elements.
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.
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.
Change Trash Auto-Empty Days
Overrides the number of days WordPress waits before permanently deleting trashed posts (default is 30 days).
Disable Core WordPress Sitemaps
Turns off the built-in WordPress XML sitemap feature when an SEO plugin already generates its own sitemap.
Prevent Loading Translation Files
Blocks specified plugins from loading their .mo translation files when the site locale is English, eliminating unnecessary disk reads.
Defer or Async Scripts by Handle
Adds defer or async attributes to specific registered script handles so they do not block HTML parsing.
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.
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.
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).
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.
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.