0
<?php
date_default_timezone_set('America/Sao_Paulo');
$date = date('Y-m-d');
if ($date >= '<?php the_sub_field("data"); ?>') { ?>
<!-- Se a data for maior -->
<a href="<?php the_sub_field('link_da_lista'); ?>">
<button class="btn btn-success"><?php the_sub_field("nome_da_lista"); ?></button>
</a>
<?php } else { ?>
<!-- Se a data for menor -->
<button class="btn btn-disabled" disabled><?php the_sub_field("nome_da_lista"); ?></button>
<?php }
?>
I am developing a portal for students, and I need to create a button that is released after a certain date that the administrator put. I am using Wordpress and a plugin called ACF - Advanced Custom Fields
Code:
<?php if(get_field('lista_de_exame')): ?>
<?php while(has_sub_field('lista_de_exame')): ?>
<?php
date_default_timezone_set('America/Sao_Paulo');
$date = date('Y-m-d');
if ($date >= '<?php the_sub_field("data); ?>') { ?>
<!-- Se a data for maior -->
<a href="<?php the_sub_field('link_da_lista'); ?>">
<button class="btn btn-success"><?php the_sub_field("nome_da_lista"); ?></button>
</a>
<?php } else { ?>
<!-- Se a data for menor -->
<button class="btn btn-disabled" disabled><?php the_sub_field("nome_da_lista"); ?></button>
<?php }
?>
However, when I put the date by the panel of Wordpress, I have no answer from script.
No need to wear that
<?php the_sub_field("data); ?>
, just use the function (without passing the opening/closing of the tag PHP).– Valdeir Psr
I have tried and still does not return the date
– Lukas Castro
Substitute
'<?php the_sub_field("data"); ?>'
forget_sub_field("nome_do_campo_criado")
– Valdeir Psr
But it will depend on the format that is the date field you created.
– Valdeir Psr
I created the Date Selector field
– Lukas Castro
Valdeir, thank you so much for the help, I managed to make wheel, it was a simple thing kkkkk just exchange the for get
– Lukas Castro