<?php /**
* Template name: Home
*/
get_header();
?>
<div class="col-lg-9 col-md-8">
<div class="blog-items_primary">
<div class="widget-heading">
<h1 class="widget-heading_title"><?php the_field('blog-title', get_option('page_for_posts')); ?></h1>
</div>
<div class="blog-items_wrapper">
<?php // the query
$wp_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish')); ?>
<?php if( $wp_query->have_posts()) : ?>
<?php while( $wp_query->have_posts()) : $wp_query->the_post(); ?>
<div class="blog-item">
<div>
<div class="blog-item_thumbnail">
<div class="blog-item_date"><?php $date = get_the_date('j.m.Y'); echo $date ?></div>
<?php
//get all the categories the post belongs to
$categories = wp_get_post_categories( get_the_ID() );
//loop through them
foreach($categories as $c){
$cat = get_category( $c );
//get the name of the category
$cat_id = get_cat_ID( $cat->name );
}
?>
<?php echo '<a class="blog-item_category" href="'.get_category_link($cat_id).'">'.$cat->name.'</a>'; ?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<a class="blog-item_thumbnail-bg" style="background-image: url(<?php echo $url; ?>"
href="<?php echo the_permalink(); ?>"></a>
</div>
</div>
<div>
<div class="blog-item_body">
<h2 class="blog-item_title"><a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a>
</h2>
<ul class="blog-item_meta-info">
<li class="blog-item_meta-author">
<a href="<?php echo get_author_posts_url($author_id).get_author_name($auth_id); ?>">
<span class="blog-item_meta-avatar">
<span style="background-image: url(<?php echo get_avatar_url($id); ?>)"></span>
</span><?php the_author(); ?>
</a>
</li>
<li><i class="fa fa-clock-o"></i><?php echo $date; ?></li>
</ul>
<div class="blog-item_content">
<p><?php the_excerpt(); ?></p>
</div>
<a class="btn-primary"
href="<?php echo the_permalink(); ?>"><?php the_field('read-more-text', get_option('page_for_posts')); ?></a>
</div>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
<div class="post-pagination">
<?php if(show_posts_nav($wp_query)) : ?>
<div class="blog-items_pagination">
<?php bittersweet_pagination(); ?>
</div>
<?php endif; ?>
</div>
</div>
</div>
<div class="col-lg-3 col-md-4">
<?php get_template_part('template-parts/sidebar'); ?>
</div>
<?php get_template_part('template-parts/newsletter'); ?>
<?php get_footer();
?>
{"html5":"htmlmixed","css":"css","javascript":"javascript","php":"php","python":"python","ruby":"ruby","lua":"text\/x-lua","bash":"text\/x-sh","go":"go","c":"text\/x-csrc","cpp":"text\/x-c++src","diff":"diff","latex":"stex","sql":"sql","xml":"xml","apl":"apl","asterisk":"asterisk","c_loadrunner":"text\/x-csrc","c_mac":"text\/x-csrc","coffeescript":"text\/x-coffeescript","csharp":"text\/x-csharp","d":"d","ecmascript":"javascript","erlang":"erlang","groovy":"text\/x-groovy","haskell":"text\/x-haskell","haxe":"text\/x-haxe","html4strict":"htmlmixed","java":"text\/x-java","java5":"text\/x-java","jquery":"javascript","mirc":"mirc","mysql":"sql","ocaml":"text\/x-ocaml","pascal":"text\/x-pascal","perl":"perl","perl6":"perl","plsql":"sql","properties":"text\/x-properties","q":"text\/x-q","scala":"scala","scheme":"text\/x-scheme","tcl":"text\/x-tcl","vb":"text\/x-vb","verilog":"text\/x-verilog","yaml":"text\/x-yaml","z80":"text\/x-z80"}