Skip to content

Instantly share code, notes, and snippets.

@daveloodts
Last active August 31, 2016 12:40
Show Gist options
  • Save daveloodts/80d3bb94bd317b7690dd53d23cade062 to your computer and use it in GitHub Desktop.
Save daveloodts/80d3bb94bd317b7690dd53d23cade062 to your computer and use it in GitHub Desktop.
add_shortcode( 'kalenderlijst', 'list_kalender' );
function list_kalender( $atts ) {
ob_start();
wp_reset_postdata();
$today = date('Ymd');
extract( shortcode_atts( array (
'type' => 'kalender',
'posts' => 3,
'category' => '',
), $atts ) );
$options = array(
'post_type' => $type,
'posts_per_page' => -1,
'order' => 'ASC',
'orderby' => 'meta_value_num',
'meta_key' => 'datum',
'meta_query' => array(array('key' => 'datum', 'value' => $today, 'compare' => '>'))
);
$query = new WP_Query( $options );
if ( $query->have_posts() ) { ?>
<?php while ( $query->have_posts() ) : $query->the_post(); ?>
<div class="kalenderblock row collapse">
<div class="small-2 large-3 columns ">
<a href="<?php the_permalink(); ?>"><?php echo the_post_thumbnail('newsimg'); ?></a>
</div>
<div class="small-9 large-8 columns">
<h5><span class="kalico date"><?php $date = get_field('datum', false, false);
$datee = strftime('%A %e %B %Y',strtotime($date)); echo $datee ?></span><span class="kalico time"><?php echo the_field('tijdstip'); ?></span></h5>
<h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo the_field('locatie'); ?></p>
<?php $subsc = get_field('online_inschrijven'); if( $subsc ): ?>
<a class="button small hollow" href="<?php the_permalink(); ?>">Online inschrijven</a>
<?php endif; ?>
</div>
</div>
<?php endwhile;
?>
<?php $myvariable = ob_get_clean();
return $myvariable;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment