
WordPress code snippets for hooks, custom post types, the REST API, WP_Query, admin screens and more. Copy, paste and adapt.

Why get_transient() keeps missing in WordPress and your expensive code runs on every load, plus a helper that caches false, empty and long-keyed values.

A custom WP-CLI command that reads every admin account straight from the database and flags admins hidden from the Users screen.

Add an Export CSV button to any WordPress post type list screen, with nonce and capability checks, terms, meta and formula-injection protection.

Register a WordPress Block Bindings source that fills core Paragraph, Heading and Button blocks with a post’s last-updated date and author.

Add categories and tags to WordPress pages and list those pages in the category and tag archives, next to your posts.

Instead of adding one by one you can include all files inside /inc/ folder If you need to load only php files

Save large WordPress image sizes at quality 100 and keep thumbnails at the default 82, with the wp_editor_set_quality filter.

Print the server port and http/https in the WordPress footer, visible to administrators only, escaped and safe to leave on while debugging.

Add a private Dev Notes page to the WordPress admin for administrators: rich text, tables, images, autosave and an HTML view, no plugin.

A WordPress countdown timer shortcode: days, hours, minutes and seconds to a date in your site’s timezone, styled with Tailwind CSS classes.

Limit WordPress wp-admin and wp-login.php to an IP allowlist with PHP, keep AJAX, REST and cron working, with a wp-config off switch.

One of our customer requested a code snippet to write a function which will check that if current post or page has a specific Oxygen template assigned.

Disable emojis in WordPress: remove the emoji script and styles on the front end and in wp-admin, plus the feed, email and TinyMCE emoji handling.

When a WordPress search finds exactly one post, page or product, send the visitor straight to it instead of a results page with one item.

Hide the WordPress admin bar on the front end for subscribers, customers or any role you list, or for everyone, without a fatal error.
3rd party plugins actions admin admin bar archive block-themes block editor Blocks block styles block theme build core CSS custom post types debugging development gutenberg hook hooks Image img javascript load styles media Must Have npm options Oxygen performance php plugins production react rest api scripts organizer security single product theme.json Tips updates WooCommerce wordpress wp-cli wp-cron WP Admin