5 edited body
source | link

<?php $args = array( 'post_type' => 'programme', 'posts_per_page' => 12, 'orderby' => 'prog_order', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'date', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'time', 'value' => '', 'compare' => 'LIKE' )
)
);

<?php $args = array(
            'post_type' => 'programme',
            'posts_per_page' => 12,
            'orderby' => 'prog_order',
            'order' => 'ASC',
            'meta_query' => array(
                array(
                    'key' => 'date',
                    'value' => '',
                    'compare' => 'LIKE'
                ),
                array(
                    'key' => 'time',
                    'value' => '',
                    'compare' => 'LIKE'
                )   
            )           
        );`

        $the_query = new WP_Query( $args );     ?>

        <?php if ( $the_query->have_posts() ) {
            $post_date = '';
            // setlocale(LC_TIME, 'nl_NL');
            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <?php $date = DateTime::createFromFormat('Ymd', get_field('date')); ?> 
            <article id="post-<?php the_ID(); ?>" <?php post_class('index-card row'); ?>>
                <?php 
                if ($post_date != $date) { 
                ?>
                    <div class="weekday"><h3><?php echo $date->format('l'); ?></h3></div>
                <?php               
                    $post_date = $date;
                } 
                ?>
                <header class="medium-4 columns text-center">
                    <div class="prog-time"><p><i class="fa fa-calendar"></i> <?php echo $date->format('d/m/Y'); ?> om <?php the_field( 'time' ); ?> uur</p></div>
                    <img src="<?php the_field( 'afbeelding' ); ?>" alt="" class="prog-img">
                    <p>Presentatie:<br /><?php the_field( 'presenter' ); ?></p>
                </header>
                <div class="entry-content medium-8 columns">
                    <h4 class="prog-title"><?php the_title(); ?></h4>
                    <h4 class="prog-sub subheader"><?php the_field( 'name' ); ?></h4>
                    <div class="prog-desc"><?php the_field( 'description' ); ?></div>
                </div>
                <hr>
            </article>
        <?php 
            endwhile; 
            } 
         ?> ` 

<?php $args = array( 'post_type' => 'programme', 'posts_per_page' => 12, 'orderby' => 'prog_order', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'date', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'time', 'value' => '', 'compare' => 'LIKE' )
)
);

        $the_query = new WP_Query( $args );     ?>

        <?php if ( $the_query->have_posts() ) {
            $post_date = '';
            // setlocale(LC_TIME, 'nl_NL');
            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <?php $date = DateTime::createFromFormat('Ymd', get_field('date')); ?> 
            <article id="post-<?php the_ID(); ?>" <?php post_class('index-card row'); ?>>
                <?php 
                if ($post_date != $date) { 
                ?>
                    <div class="weekday"><h3><?php echo $date->format('l'); ?></h3></div>
                <?php               
                    $post_date = $date;
                } 
                ?>
                <header class="medium-4 columns text-center">
                    <div class="prog-time"><p><i class="fa fa-calendar"></i> <?php echo $date->format('d/m/Y'); ?> om <?php the_field( 'time' ); ?> uur</p></div>
                    <img src="<?php the_field( 'afbeelding' ); ?>" alt="" class="prog-img">
                    <p>Presentatie:<br /><?php the_field( 'presenter' ); ?></p>
                </header>
                <div class="entry-content medium-8 columns">
                    <h4 class="prog-title"><?php the_title(); ?></h4>
                    <h4 class="prog-sub subheader"><?php the_field( 'name' ); ?></h4>
                    <div class="prog-desc"><?php the_field( 'description' ); ?></div>
                </div>
                <hr>
            </article>
        <?php 
            endwhile; 
            } 
         ?> ` 
<?php $args = array(
            'post_type' => 'programme',
            'posts_per_page' => 12,
            'orderby' => 'prog_order',
            'order' => 'ASC',
            'meta_query' => array(
                array(
                    'key' => 'date',
                    'value' => '',
                    'compare' => 'LIKE'
                ),
                array(
                    'key' => 'time',
                    'value' => '',
                    'compare' => 'LIKE'
                )   
            )           
        );`

        $the_query = new WP_Query( $args );     ?>

        <?php if ( $the_query->have_posts() ) {
            $post_date = '';
            // setlocale(LC_TIME, 'nl_NL');
            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <?php $date = DateTime::createFromFormat('Ymd', get_field('date')); ?> 
            <article id="post-<?php the_ID(); ?>" <?php post_class('index-card row'); ?>>
                <?php 
                if ($post_date != $date) { 
                ?>
                    <div class="weekday"><h3><?php echo $date->format('l'); ?></h3></div>
                <?php               
                    $post_date = $date;
                } 
                ?>
                <header class="medium-4 columns text-center">
                    <div class="prog-time"><p><i class="fa fa-calendar"></i> <?php echo $date->format('d/m/Y'); ?> om <?php the_field( 'time' ); ?> uur</p></div>
                    <img src="<?php the_field( 'afbeelding' ); ?>" alt="" class="prog-img">
                    <p>Presentatie:<br /><?php the_field( 'presenter' ); ?></p>
                </header>
                <div class="entry-content medium-8 columns">
                    <h4 class="prog-title"><?php the_title(); ?></h4>
                    <h4 class="prog-sub subheader"><?php the_field( 'name' ); ?></h4>
                    <div class="prog-desc"><?php the_field( 'description' ); ?></div>
                </div>
                <hr>
            </article>
        <?php 
            endwhile; 
            } 
         ?> 
4 added 35 characters in body
source | link

Edit: This is the working code, based on the example by @s_ha_dum that makes the weekday only display once in the loop, as long as it is on the same date.

Edit: This is the working code that makes the weekday only display once in the loop, as long as it is on the same date.

Edit: This is the working code, based on the example by @s_ha_dum that makes the weekday only display once in the loop, as long as it is on the same date.

3 added 1833 characters in body
source | link

Edit: This is the working code that makes the weekday only display once in the loop, as long as it is on the same date.

<?php $args = array( 'post_type' => 'programme', 'posts_per_page' => 12, 'orderby' => 'prog_order', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'date', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'time', 'value' => '', 'compare' => 'LIKE' )
)
);

        $the_query = new WP_Query( $args );     ?>

        <?php if ( $the_query->have_posts() ) {
            $post_date = '';
            // setlocale(LC_TIME, 'nl_NL');
            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <?php $date = DateTime::createFromFormat('Ymd', get_field('date')); ?> 
            <article id="post-<?php the_ID(); ?>" <?php post_class('index-card row'); ?>>
                <?php 
                if ($post_date != $date) { 
                ?>
                    <div class="weekday"><h3><?php echo $date->format('l'); ?></h3></div>
                <?php               
                    $post_date = $date;
                } 
                ?>
                <header class="medium-4 columns text-center">
                    <div class="prog-time"><p><i class="fa fa-calendar"></i> <?php echo $date->format('d/m/Y'); ?> om <?php the_field( 'time' ); ?> uur</p></div>
                    <img src="<?php the_field( 'afbeelding' ); ?>" alt="" class="prog-img">
                    <p>Presentatie:<br /><?php the_field( 'presenter' ); ?></p>
                </header>
                <div class="entry-content medium-8 columns">
                    <h4 class="prog-title"><?php the_title(); ?></h4>
                    <h4 class="prog-sub subheader"><?php the_field( 'name' ); ?></h4>
                    <div class="prog-desc"><?php the_field( 'description' ); ?></div>
                </div>
                <hr>
            </article>
        <?php 
            endwhile; 
            } 
         ?> ` 

Edit: This is the working code that makes the weekday only display once in the loop, as long as it is on the same date.

<?php $args = array( 'post_type' => 'programme', 'posts_per_page' => 12, 'orderby' => 'prog_order', 'order' => 'ASC', 'meta_query' => array( array( 'key' => 'date', 'value' => '', 'compare' => 'LIKE' ), array( 'key' => 'time', 'value' => '', 'compare' => 'LIKE' )
)
);

        $the_query = new WP_Query( $args );     ?>

        <?php if ( $the_query->have_posts() ) {
            $post_date = '';
            // setlocale(LC_TIME, 'nl_NL');
            while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
            <?php $date = DateTime::createFromFormat('Ymd', get_field('date')); ?> 
            <article id="post-<?php the_ID(); ?>" <?php post_class('index-card row'); ?>>
                <?php 
                if ($post_date != $date) { 
                ?>
                    <div class="weekday"><h3><?php echo $date->format('l'); ?></h3></div>
                <?php               
                    $post_date = $date;
                } 
                ?>
                <header class="medium-4 columns text-center">
                    <div class="prog-time"><p><i class="fa fa-calendar"></i> <?php echo $date->format('d/m/Y'); ?> om <?php the_field( 'time' ); ?> uur</p></div>
                    <img src="<?php the_field( 'afbeelding' ); ?>" alt="" class="prog-img">
                    <p>Presentatie:<br /><?php the_field( 'presenter' ); ?></p>
                </header>
                <div class="entry-content medium-8 columns">
                    <h4 class="prog-title"><?php the_title(); ?></h4>
                    <h4 class="prog-sub subheader"><?php the_field( 'name' ); ?></h4>
                    <div class="prog-desc"><?php the_field( 'description' ); ?></div>
                </div>
                <hr>
            </article>
        <?php 
            endwhile; 
            } 
         ?> ` 
2 added 246 characters in body
source | link
1
source | link