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

Set the theme-color meta tag in WordPress so mobile browsers paint their address bar and top of the screen in your brand colour.

Show a red WordPress admin notice on every screen while “Discourage search engines from indexing this site” is ticked, so a live site is not left hidden.

Make every published post of a WordPress custom post type private automatically, while drafts, trash and other post types work as usual.

A WordPress reading time shortcode that counts the raw post words, skips blocks and shortcodes, and works in content and templates.

Add an Image column with the featured image to the WordPress admin lists of posts, pages and custom post types, without an extra image size.

Two WooCommerce shortcodes that show the cart total or item count anywhere in WordPress and update without a reload when products are added.

Exclude WordPress post types and taxonomies from the Slim SEO sitemap.xml with two filters, for helper post types nobody should find.

Are you Curious how to remove the slug of a custom post type in WordPress? If you’re using CPT UI, there’s an option called With Front but that doesn’t always seem to work. Follow this tutorial, add these two simple functions and the slug will be removed from your custom post type URL. Note –…

Remove the Category:, Tag:, Author: and Archives: prefix from WordPress archive titles with one filter, and keep it where you still want it.

A WooCommerce cart icon shortcode with the item count that links to the cart, updates over AJAX and works in block themes and builders.

For retrieving the best buying products in WooCommerce we are using wp_query manipulation with meta_key as “total_sales” and orderby “meta_value_num”. In short we are displaying products as per the total sales number. Here is Screenshot for repeater / easy posts Step 1 – Select Advance WP Query Step 2 – Setup Advance WP Query as…

Add a short text after the WooCommerce product price, for all products or chosen product IDs, on product pages and shop lists, escaped and valid HTML.

Oxygen does not support WordPress wp_body_open() and if you need to integrate Google Tag manager it requires two code parts. 1st part is Inside Head and 2nd is inside Body. Lucky Oxygen provides hook that is called: ct_before_builder. If you are using Scripts Organizer , Code Snippets or any other functionality plugins this script will…

This technique requests Scripts Manager feature by Swiss Knife or Scripts Organizer to quickly import a script. Register Script We will start by going into Script Manager feature and paste CDN link or Upload it to media library to store it on our server. Give it a name, Script Type set as JavaScript, Location for…

Add a Pages dropdown to the WordPress admin bar with an edit link for every page, shown only to users who can edit pages.

Reload the WordPress front end automatically when you save a Scripts Organizer code block. Admins only, visible tab only, no fixed-timer reloads.

A WordPress YouTube shortcode that shows a thumbnail and loads the privacy-friendly youtube-nocookie player only when the visitor clicks play.

Add an ID column to the WordPress admin lists of posts, pages and custom post types, so you never open a post just to find its ID.
3rd party plugins actions admin admin bar archive block-themes block editor block theme build capabilities core CSS custom post types database debugging development filters full site editing gutenberg hook hooks Image load styles maintenance media mu-plugin Must Have npm Oxygen performance php plugins rest api scripts organizer security single product theme.json Tips transients updates users WooCommerce wordpress wp-cli WP Admin