Release button after certain date

Asked

Viewed 35 times

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).

  • I have tried and still does not return the date

  • 1

    Substitute '<?php the_sub_field("data"); ?>' for get_sub_field("nome_do_campo_criado")

  • But it will depend on the format that is the date field you created.

  • I created the Date Selector field

  • Valdeir, thank you so much for the help, I managed to make wheel, it was a simple thing kkkkk just exchange the for get

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.