Archives by year: 2020

Meta Boxes Conditional Logic

In this tutorial I will explain you how to show or hide a field depending on a value of another field within a simple WordPress metabox.

Like this:

conditional logic in WordPress meta boxes
Show or hide a custom field depending on a value of another field.

Add Custom Fields to a Taxonomy

In this tutorial I will show you step by step how to add a custom field to a custom taxonomy in WordPress. Of course, this method is going to work great for default taxonomies as well.

First of all I will show you how to do it without any plugins and then we will do the same with the help of my Simple Fields plugin, so you can see the difference.

Well, let’s take a look what we are going to create here.

WordPress custom fields in taxonomy
Here I decided to add multiple fields – a simple text field and an image field.

And this is how it looks when you go edit a specific taxonomy term:

add custom fields on edit term pages

Create Custom Options Pages

WordPress custom settings pages are quite useful when you are developing a plugin or a theme. You will definitely need some place in admin area where users can configure your plugin and Settings API is perfect for that.

And yes, we are going to use Settings API which will help us creating our options pages. It was added in WordPress 2.7 only. I really doubt that you are using a WordPress version prior 2.7, but anyway I think I have to mention that.

Below is the screenshot of a settings page we are going to create in this tutorial. I decided to make it simple, so we have multiple fields – a text field and a checkbox.

how to create a WordPress option page with field validation

Disable WooCommerce Blocks

In this tutorial I am going to show you two options:

  1. First of all we are going to turn off WooCommerce Gutenberg blocks in settings (Block Manager).
  2. If it is not enough, then I will show how to completely disable specific WooCommerce blocks (or all of them).

As a result we will do something like this:

Disable WooCommerce blocks with allowed_block_types_all hook

And we are going to do that without plugins!