Created
April 1, 2019 13:45
-
-
Save CarlasHub/7c7fa42d7e5c354284fcbadd661061e0 to your computer and use it in GitHub Desktop.
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: blog feed | |
*/ | |
get_header(); | |
$blogPosts = handleJsonCache(array( | |
'expirySeconds' => -1, | |
'fileName' => 'blog-feed' | |
), function () { | |
$query = new WP_Query(array( | |
'posts_per_page' => 4, | |
'post_type' => 'post', | |
'order' => 'DESC', | |
'orderby' => 'date' | |
)); | |
$posts = array(); | |
while ($query->have_posts()) { | |
$query->the_post(); | |
$img = get_field('thumbnail'); | |
$posts[] = array( | |
'date' => get_the_date('D, M d, Y'), | |
'thumbnail' => get_field('thumbnail'), | |
'title' => wp_trim_words(get_the_title(), 8) . '...', | |
'url' => get_the_permalink(), | |
'excerpt' => get_the_excerpt(), | |
); | |
} | |
wp_reset_postdata(); | |
return $posts; | |
}); | |
if (count($blogPosts) == 0) { | |
return; | |
} | |
?> | |
<section class="hearing-health"> | |
<?php | |
$image = get_field('banner'); | |
include 'parts/flexible-layout.php'; | |
?> | |
</section> | |
<div class="container pt-5"> | |
<div class="row"> | |
<div class="col-md-8 col-sm-12 "> | |
<!-- breadcrumbs --> | |
<?php | |
if ( | |
get_post_type() != 'branch' && | |
($blockCount == 0 || ($blockCount == 1 && $previousLayout == 'banner_form_right')) | |
) { | |
?> | |
<p class="bread-crumb pt-5">You are here: <a class="text-grey" href="<?php echo get_site_url(); ?>">Home</a> > <strong><?php the_title(); ?></strong></p> | |
<?php | |
} | |
?> | |
<p class="py-4">Keep up to date with the world of hearing healthcare, from the latest technology | |
trends and news stories through to helpful guides that can help you get the most | |
out of your hearing</p> | |
</div> | |
</div> | |
</div> | |
<?php foreach ($blogPosts as $blogPost) { ?> | |
<div class="container blog-feed py-4"> | |
<div class="row"> | |
<div class="col-lg-4 col-sm-12 offset-left-lg-2"> | |
<a class="blog-title text-dark-blue" href="<?php echo $blogPost['url']; ?>"><h3><?php echo $blogPost['title']; ?></h3></a> | |
<br> | |
<span class="small text-dark-blue"><?php echo $blogPost['date']; ?></span> | |
<div class="thumb-placeholder position-relative" role="img" aria-label="<?php echo $blogPost['title']; ?>" style="background-image: url('<?php echo $blogPost['thumbnail']; ?>');"> | |
<a href="<?php echo $blogPost['url']; ?>" class="fill-parent-area"></a> | |
</div> | |
</div> | |
<div class="col-md-4 col-sm-12 pt-4"> <div class="pt-4 excerpt"><?php the_excerpt_embed()?></div> </div> | |
</div> | |
</div> | |
</div> | |
<?php } ?> | |
<div class="cta-large py-5 text-center"> | |
<h1>Book a <a href="" class="text-pink-primary">FREE</a>, no obligation hearing test</h1> | |
</div> | |
<?php | |
get_footer(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment