Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Events In This Program
- function program_events()
- {
- ob_start(); // start buffer
- $documents = get_posts(array(
- 'post_type' => 'events',
- 'meta_query' => array(
- array(
- 'key' => 'program', // name of custom field
- 'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
- 'compare' => 'LIKE'
- )
- )
- ));
- ?>
- <?php if ($documents) : ?>
- <div class="post-it yellow upcoming">
- <div class="title">Upcoming Events</div>
- <?php foreach ($documents as $document) : ?>
- <?php $displaydate = get_field('display_date', $document->ID); ?>
- <?php $locationname = get_field('location_name', $document->ID); ?>
- <?php $locationcity = get_field('location_city', $document->ID); ?>
- <?php $locationstate = get_field('location_state', $document->ID); ?>
- <div class="event">
- <div class="eventname"><a href="<?php echo get_permalink($document->ID); ?>"><?php echo get_the_title($document->ID); ?></a></div>
- <div class="event-icons">
- <span><i class="fas fa-calendar"></i><?php echo $displaydate;?></span>
- <span class="margin-left-10"><i class="fas fa-globe-americas"></i><?php echo $locationname;?> - <?php echo $locationcity;?>, <?php echo $locationstate;?></span>
- </div>
- </div>
- <?php endforeach; ?>
- </div>
- <?php endif;
- $output = ob_get_clean(); // set the buffer data to variable and clean the buffer
- return $output;
- }
- add_shortcode('these_events', 'program_events');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement