Advertisement
Guest User

Untitled

a guest
May 27th, 2020
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. //Events In This Program
  2. function program_events()
  3. {
  4. ob_start(); // start buffer
  5. $documents = get_posts(array(
  6. 'post_type' => 'events',
  7. 'meta_query' => array(
  8. array(
  9. 'key' => 'program', // name of custom field
  10. 'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
  11. 'compare' => 'LIKE'
  12. )
  13. )
  14. ));
  15. ?>
  16. <?php if ($documents) : ?>
  17. <div class="post-it yellow upcoming">
  18. <div class="title">Upcoming Events</div>
  19. <?php foreach ($documents as $document) : ?>
  20. <?php $displaydate = get_field('display_date', $document->ID); ?>
  21. <?php $locationname = get_field('location_name', $document->ID); ?>
  22. <?php $locationcity = get_field('location_city', $document->ID); ?>
  23. <?php $locationstate = get_field('location_state', $document->ID); ?>
  24. <div class="event">
  25. <div class="eventname"><a href="<?php echo get_permalink($document->ID); ?>"><?php echo get_the_title($document->ID); ?></a></div>
  26. <div class="event-icons">
  27.  
  28.  
  29. <span><i class="fas fa-calendar"></i><?php echo $displaydate;?></span>
  30. <span class="margin-left-10"><i class="fas fa-globe-americas"></i><?php echo $locationname;?> - <?php echo $locationcity;?>, <?php echo $locationstate;?></span>
  31. </div>
  32. </div>
  33. <?php endforeach; ?>
  34. </div>
  35.  
  36.  
  37. <?php endif;
  38.  
  39. $output = ob_get_clean(); // set the buffer data to variable and clean the buffer
  40. return $output;
  41. }
  42. add_shortcode('these_events', 'program_events');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement