Skip to content

Instantly share code, notes, and snippets.

@awakekat
Created February 17, 2019 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save awakekat/2f8712e3b1081f3643a5318347a5f381 to your computer and use it in GitHub Desktop.
Save awakekat/2f8712e3b1081f3643a5318347a5f381 to your computer and use it in GitHub Desktop.
Custom Dates WP Loop #2
<?php
/* Template Name: Services Template */
get_header(); ?>
<div id="primary" <?php astra_primary_class(); ?>>
<?php astra_primary_content_top(); ?>
<?php // CUSTOM SERVICES LOOP
$today = current_time('Ymd');
$args = array(
'post_type' => 'service',
'meta_key' => 'service_date',
'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();
?>
<div id="star">
<div>
<h5 class="star-date">
<strong><?php the_field('service_date'); ?></strong>
</h5>
<div class="star-title">
<h3 style="font-weight:bold; margin-bottom: 15px;"><?php the_field('service_title'); ?></h3>
<div class="star-img">
<?php
the_post_thumbnail();
?>
</div><!-- /.star-img -->
<p class="star-desc"><?php the_field('service_desc') ?></p>
</div><!-- /.star-title -->
</div><!-- /blank -->
</div><!-- /.star -->
<hr class="str-divider">
<?php endwhile; else: ?>
No Posts Found
<?php endif; wp_reset_query(); ?>
<?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