Show or Hide Gutenberg Editor Blocks Based on Advanced Custom Fields (ACF) Value

Hide Gutenberg Block Based on ACF Field Value

In this tutorial, I’m going to walk you through Block Options Plugin’s integration with Advanced Custom Fields. Using these free WordPress plugins, you can show or hide Gutenberg block based on ACF value and specific condition.

Step 1

You need to download and install both Block Options and Advanced Custom Fields plugins. Alternatively, you can Block Options get it on the plugin directory.

Step 2

Make sure you create ACF fields; then, go to Settings > Block Options and activate Advanced Custom Fields Support.

Enable Block Options ACF Support Feature

Step 3

Now create or edit any post/page on the Gutenberg Editor. Click any block, and on the sidebar settings, scroll down to Block Option’s Advanced Custom Fields panel section.

  1. Select Show or Hide Block if the condition is met.
  2. Choose the ACF field that you want to connect.
  3. Select condition to either Equal To, Not Equal To, Contains, Does Not Contain, Is Empty or Is Not Empty.
  4. Then set the conditional value.
Hide Gutenberg Block Based on ACF Field Value

That’s it! Pretty simple, isn’t it? If you have any suggestions, please leave them through the comment section below. You can also explore other Block Options features, and here are the guides that will help you out.

Optional for Developers

If you are looking for other ways to manage any Gutenberg Blocks, you can use the Display Logic options. This will allow you to use PHP conditional functions to manage block’s visibility. With this, you’ll have full control over your Gutenberg Blocks.

One comment

  1. Thank you. But i expected something else in conjunction with ACF:
    i need to add one checkbox or input field to each block where i can save a value. For instance a custom classname. Then based on this classname, i want to wrap the whole block(-row) in a div with the custom class!
    so i thought with you plugin i can add a new input field to each block.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.