Support » Plugin: Advanced Custom Fields » Problem with Custom Fields and Events

  • Hello there people… So this is my frist topic because I’m having a problems with setting up dinamic date onto my wordpress theme… I’m learning to become wordpress developer btw 😀 So here is the problem, I installed ‘Advanced Custom Fields’ plugin to make custom field for my event posts, I made seperate sections outside post and pages for events in wp-admin… So I added new custom field for dates on my ‘events’ and I added manually dates on events which I already created before… and to make it dinamic I edited the code in the theme, but dates just don’t want to change according to those ones which I set them to be… here is the code, I don’t know what am I doing wrong…

    <?php
    
              $homepagePosts = new WP_Query(array(
                'posts_per_page' => 2,
              ));
    
              while ($homepagePosts->have_posts()) {
                $homepagePosts->the_post(); ?>
                <div class="event-summary">
                  <a class="event-summary__date event-summary__date--beige t-center" href="<?php the_permalink(); ?>">
                    <span class="event-summary__month"><?php
                      $eventDate = new DateTime(get_field('event_date'));
                      echo $eventDate->format('M')
                     ?></span>
                    <span class="event-summary__day"><?php the_time('d'); ?><?php echo $eventDate->format('d') ?></span>
                  </a>
                  <div class="event-summary__content">
                    <h5 class="event-summary__title headline headline--tiny"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
                    <p><?php if (has_excerpt()) {
                      echo get_the_excerpt();
                    }
                      else {
                        echo wp_trim_words(get_the_content(), 18);
                      }
                    ?><a href="<?php the_permalink(); ?>" class="nu gray">Read more</a></p>
                  </div>
                </div>
  • You must be logged in to reply to this topic.