Get Product Stock Quantity

In this tutorial I will not only show you how to get stock quantity in WooCommerce (of a product or a product variation by the way) but we will also display it on the shop page. Like this:

displaying only one left in stock on WooCommerce shop page

Create Multiple Posts At Once

What is interesting here is that if you try to google the title of this post you will find a lot of plugins and most of them are outdated and no articles or code examples.

In this tutorial I am going to guide you through the process of bulk creating posts, we will not only create posts or pages automatically, but also try to use the data from Lorem Ipsum generators or Open AI (ChatGPT).

Display Plugin Sidebars and Custom Fields for Specific Page Templates Only

We kind of did the similar thing on my blog, when we restrict displaying <PanelBody> only for specific post types. In this tutorial we are going to do almost the same, but for the condition we take a page template selected for post.

This is an example how it is going to work:

display Gutenberg panels for specific post templates only
So, “Contact page settings” section is visible only if “Contact us” page template is selected.

Creating MetaMask Payment Gateway for WooCommerce

Recently I really enjoyed creating a tutorial about signing in to WordPress with MetaMask, so I decided to continue with this topic and today I will show you how you can create a payment gateway for WooCommerce that allows to pay with MetaMask extension.

I also would like to remind that I already have a complete payment gateway tutorial and additionally a tutorial about paying with crypto. So you can check them out as well.

And this how it is going to work on our WooCommerce store:

MetaMask Payment Gateway for WooCommerce
This is what happens when you click Connect wallet (Place order) button on your WooCommerce checkout page.

One-click WordPress Login With MetaMask

In this tutorial I will show you how you can add “Login with MetaMask” button to your WordPress login page. Once you click on it, you will signed in to WordPress dashboard. Here is how it is going to work:

Login flow with MetaMask for WordPress
It is pretty much how it is going to work. The only thing, once you’ve already connected MetaMask there are going to be less steps – just “Signature request” modal window, that’s all.

How to Create a Shared Media Library in Multisite Network

Every once in a while I am receiving questions about my Simple Multisite Crossposting plugin whether it works with shared media library plugins or not (yes – it works). And when I decided to test it I figured it out that there are multiple shared media library plugins out there and every one of them works a little bit differently.

The key idea of most of these plugins is to store all the media on one “main” blog and not necessarily it should be the blog with ID = 1. Then some of them use switch_to_blog() function every time you’re working with attachments on subsites, the other ones even create attachments in database linked to original files on all subsites (I assume it could lead to issues by the way).

Most of all I like a switch_to_blog() approach because it seems unharmful, you can even stop using network media library any time, just deactivate the plugin and continue to use your websites as usual.

How to Add CSS to Block Editor Based on Post Type

I have multiple post types on my website, for example you’re reading a normal post, but there are also support articles like this one. The posts are almost similar except one thing – the heading font size.

It is quite easy to change the title font size depending on a post type on a website, you just have to make sure that your theme is using body_class() function and then you can use a CSS selector like .single-{post type} h1, but this way will never work in Gutenberg! So please don’t try to add classes via admin_body_class or anything like this.