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

Add Featured Images to RSS Feed

Prepends the post's featured image to both the full-content and excerpt RSS feed items.

#content#feed#images
PHP

Add Slug and Category Body Classes

Adds the current page slug and post category slugs as extra CSS body classes for precise per-page styling.

#body-class#css#display
PHPPro

Keep Sticky Posts on Archives

Reorders archive query results so that sticky posts always appear first on category, tag, and date archives.

#archives#display#frontend
PHPPro

Related Posts by Shared Tags

Appends a list of related posts based on shared tags after single post content.

#content#engagement#posts
PHP

Child Pages List Shortcode

Shortcode [scseed_child_pages] that lists the immediate sub-pages of the current (or a specified) page.

#display#hierarchy#navigation
PHP

Recently Updated Posts Shortcode

Shortcode [scseed_recently_updated] that lists posts ordered by last-modified date.

#content#dates#display
PHPPro

Popular Posts by Views Shortcode

Tracks post view counts in meta and provides a [scseed_popular_posts] shortcode that outputs the most-viewed posts.

#analytics#popular#posts
PHP

Random Posts Shortcode

Shortcode [scseed_random_posts] that outputs a randomised list of published posts.

#content#display#posts
PHP

"New" Badge for Recent Posts

Appends a "New" badge to post titles in list views for posts published within the last 7 days.

#content#display#frontend
PHP

Show Modified Instead of Published Date

Replaces the displayed post date with the last-modified date on single posts.

#content#dates#display
PHP

Display Last Updated Date

Appends the post's last-modified date below the content on single posts.

#content#dates#display
PHPPro

Disable Comments Site-Wide

Completely disables WordPress comments: closes them on all post types, removes the Comments menu, hides the admin bar node, and suppresses existing comments.

#admin#cleanup#comments
PHPPro

Add Custom Post Type Count to At a Glance Widget

Appends a published-count entry for a custom post type (default: 'product') to the Dashboard At a Glance widget.

#admin#custom-post-types#dashboard
PHPPro

Restrict Media Library to Own Uploads

Limits non-administrator users to viewing and managing only their own uploaded media files in the Media Library.

#admin#media#permissions
PHPPro

Redirect to Live Post After Publishing

After a post is newly published the editor is redirected to the live post URL instead of remaining on the edit screen.

#admin#posts#redirects
PHPPro

Add Settings Link to a Plugin on the Plugins Page

Prepends a Settings action link for a specific plugin on the Plugins admin list — update the plugin basename and settings URL as needed.

#admin#plugins#settings
PHPPro

Duplicate Post Row Action

Adds a nonce-protected Duplicate row action to the Posts list that creates a draft copy including all post meta and taxonomy terms.

#admin#duplicating#posts
PHPPro

Custom Dashboard Welcome Widget

Registers a branded quick-start widget on the admin dashboard showing live post, page, and comment counts with action buttons.

#admin#branding#dashboard
PHPPro

Role-Based Login Redirect

Sends users to different URLs after login depending on their WordPress role, e.g. subscribers to /account/ and editors to the post list.

#login#redirects#roles
PHPPro

Track and Display Last Login in Users List

Records each user's last login timestamp and displays it as a sortable column in the Users admin list table.

#admin#columns#security
PHPPro

Custom Login Logo, URL, and Title

Replaces the WordPress logo on the login page with the site's custom logo, linking back to the homepage.

#branding#customization#login
PHP

Redirect Subscribers Away from wp-admin

Redirects logged-in users who lack editing capabilities to the homepage when they try to access wp-admin.

#admin#roles#security
PHP

Remove Default Dashboard Widgets

Removes the Quick Draft, WordPress Events & News, and Activity widgets from the admin dashboard.

#admin#cleanup#dashboard
PHP

Custom WordPress Email From Name and Address

Changes the default WordPress email sender name and address to your site name and a noreply alias.

#admin#branding#email