Hi everyone, I would like to know if it’s possible to directly embed the PHP or JavaScript script (current date) in the conditional section. Please refer to the image for more information. Thank you very much. @Emmanuel @matjaz
@JuniorZabunga you can’t use Block Condition with dynamic values.
But, this appears to be a dynamic PHP block and you can use any PHP code and WP actions there.
For example, add “IF Options” action to the element you want to control with the condition:
The source code of this test block is:
<section cms-block="test-condition" cms-block-title="Test Condition" cms-block-field="event_date" cms-block-field-type="none" cms-block-field-title="Event date" cms-block-type="native-dynamic">
<h1 wp-if-custom="PG_Blocks_v4::getAttribute( $args, 'event_date', false ) <= the_time('Y/m/d')">The condition is true</h1>
</section>
One recommendation:
Using PG_Blocks_vX helpers in your custom code might be a problem because the version is updated occassionaly and then you’ll have to update the code. Instead you can just use plain php to get the block attribute field like this:
$args['attributes'][‘event_date’]
1 Like
@matjaz Thank you for the explanation.
1 Like

