Home / WordPress and WooCommerce Code Snippets

WordPress and WooCommerce Code Snippets

These are the WordPress and WooCommerce code snippets I keep coming back to. Where a snippet has its own post, the post explains it and was tested again in November 2026 on WordPress 7.1.4, WooCommerce 11.2.2 and PHP 8.4. The rest live as GitHub Gists, so test them on a staging site before you use them on a live one.

Add PHP snippets to a child theme’s functions.php or a small plugin, not to a parent theme you update. All of them are on GitHub (opens in a new tab) under the GPL-3.0 licence, and the posts are also listed in Code Snippets.

WooCommerce Subscriptions

These need the WooCommerce Subscriptions extension.

Checkout, shipping and accounts

Products and the shop

Security and server

Admin and users

Search, taxonomies and post types

SEO and Yoast

Older snippets

These are for older tools such as Bootstrap 3, WOW.js, Visual Composer and OpenCart. I keep them for reference, but I don’t maintain them.

Show older snippets

I used AI to help draft this post from my own idea and notes. I verified the information and edited the text myself.