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

Register custom image sizes in WordPress and show them in the editor image size dropdown, from one config with name, width, height and crop.

A WordPress admin dark theme in a few lines of CSS: dark wp-admin screens and block editor UI, real colours for images and the editor canvas.

At the moment we have option to select pages on which you want to apply scripts. Thats why I made a small code snippet to help you create this option as well. Write Page, Post ID or Slug on witch pages you don’t want that script is applied and it will be applied on all…

Slow down the WordPress Heartbeat API and switch it off on the front end or in wp-admin, without breaking post locks or a plugin.

Change the WordPress widget title tag from h2 to h4 (or any heading) for every sidebar, keeping the theme’s classes and the title text as they are.

Remove “Category:”, “Tag:”, “Archives:” and the other prefixes from WordPress archive titles with one filter, in classic and block themes.

Color chosen WordPress admin menu items with your own background and text colours, so the screens you use daily stand out in the sidebar.

Give a WordPress custom post type the normal Categories and Tags and show those posts on category and tag archives, with or without Custom Post Type UI.

Show any taxonomy as a column in WordPress admin post lists, including custom post types, with one config array and no placeholders.

Give WordPress posts or custom post types a Parent field like pages, with register_post_type_args, safe for post types registered without supports.

Place it above Repeater or East Posts

Change the order of the WordPress blog and archive loop, for example oldest posts first, with pre_get_posts and without touching templates.

This one is work in progress

Show WordPress previous and next post links with the title and featured image under a single post, with escaped output and no errors on the first post.

Stop WordPress compressing resized images at quality 82: set your own JPEG and WebP quality with the wp_editor_set_quality filter.

Limit WordPress search results to the post types you choose, such as posts and pages, without touching admin, REST or custom queries.

Product cat is category name for WooCommerce products category. Thanks, Hammad Wali for sharing this useful code!

Print a WordPress excerpt without HTML tags, shortcodes or a read-more link, cut to a word limit, for cards and templates.

Print just the WordPress category, tag, taxonomy, post type or author archive name in your archive template, without the Category: prefix.
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