Last active
February 17, 2019 20:13
-
-
Save awakekat/8511e80b20fd7b41386a52d3e404e9bb to your computer and use it in GitHub Desktop.
Custom WP Dated Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Template Name: Front Page Template */ | |
get_header(); ?> | |
<div id="primary" <?php astra_primary_class(); ?>> | |
<?php astra_primary_content_top(); ?> | |
<div style="background-color: #F2EBCB;padding:15px 15px 0 15px;"> | |
<h3 style="text-align:center;padding-bottom:15px;text-weight:bold;">Upcoming Sunday Services:</h3> | |
<div style="display:flex;flex-direction:row;width:75%;margin:0 auto;"> | |
<?php | |
// CUSTOM FRONT PAGE SERVICES LOOP | |
$today = current_time('Ymd'); | |
$args = array( | |
'post_type' => 'service', | |
'meta_key' => 'service_date', | |
'posts_per_page' => 2, | |
'order' => 'ASC', | |
'orderby' => 'meta_value', | |
'meta_query' => array( | |
array( | |
'key' => 'service_date', | |
'compare' => '>=', | |
'value' => $today, | |
), | |
), | |
); | |
$loop = new WP_QUERY($args); | |
if ($loop->have_posts() ) : | |
while($loop->have_posts() ) : | |
$loop->the_post(); | |
?> | |
<span style="width:48%;text-align:left;"> | |
<strong><?php the_field('service_date'); ?> - | |
<?php the_field('service_title'); ?></strong> | |
<?php the_excerpt(); ?> | |
</span> | |
<?php endwhile; else: ?> | |
No Posts Found | |
<?php endif; wp_reset_query(); ?> | |
</div> | |
</div> | |
<?php astra_content_page_loop(); ?> | |
<?php astra_primary_content_bottom(); ?> | |
</div><!-- #primary --> | |
<?php get_footer(); ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment