Created
December 27, 2022 21:06
-
-
Save krstivoja/c9968f6998712f6a35f62ce6bb6f7fb1 to your computer and use it in GitHub Desktop.
Gutenberg ACF Condition Block
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( !empty(get_field('condition')) ): // Check if condition is applied ?> | |
<?php // Display if condition is valid | |
$condition = get_field('condition'); | |
if(eval("return $condition;")): ?> | |
<InnerBlocks /> | |
<?php else: // If condition is not valid display message ?> | |
<h2><?php the_field('message'); ?></h2> | |
<?php endif; // end of if field_name logic ?> | |
<?php else: // If condition is not set display content ?> | |
<InnerBlocks /> | |
<?php endif; // end of if field_name logic ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment