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

Stop posts from being published until a category and one of its subcategories are checked. Save Draft keeps working, and the editor shows the error.

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.
3rd party plugins actions admin archive block-themes block editor Blocks block theme build capabilities core CSS Custom Post custom post types Developer development filters Front End full site editing gutenberg hook Image img load styles maintenance media mu-plugin Must Have npm Oxygen performance php plugins scripts organizer security SEO settings api single product theme.json Tips updates WooCommerce wordpress wp-cli WP Admin