Facebook
From Torrid Iguana, 4 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 233
  1. <?php /**
  2.  * Template name: Home
  3.  */
  4.  
  5. get_header();
  6.  
  7. ?>
  8.  
  9.  
  10.  
  11. <div class="col-lg-9 col-md-8">
  12.     <div class="blog-items_primary">
  13.         <div class="widget-heading">
  14.             <h1 class="widget-heading_title"><?php the_field('blog-title', get_option('page_for_posts')); ?></h1>
  15.         </div>
  16.         <div class="blog-items_wrapper">
  17.             <?php // the query
  18.                         $wp_query = new WP_Query(array('post_type'=>'post', 'post_status'=>'publish')); ?>
  19.             <?php if(  $wp_query->have_posts()) : ?>
  20.             <?php while(  $wp_query->have_posts()) :  $wp_query->the_post(); ?>
  21.             <div class="blog-item">
  22.                 <div>
  23.                     <div class="blog-item_thumbnail">
  24.  
  25.                         <div class="blog-item_date"><?php $date = get_the_date('j.m.Y'); echo $date ?></div>
  26.  
  27.                         <?php
  28.                         //get all the categories the post belongs to
  29.                         $categories = wp_get_post_categories( get_the_ID() );
  30.                         //loop through them
  31.                         foreach($categories as $c){
  32.                         $cat = get_category( $c );
  33.                         //get the name of the category
  34.                         $cat_id = get_cat_ID( $cat->name );
  35.                         }
  36.                          ?>
  37.  
  38.                         <?php echo '<a class="blog-item_category" href="'.get_category_link($cat_id).'">'.$cat->name.'</a>'; ?>
  39.  
  40.                         <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
  41.  
  42.                         <a class="blog-item_thumbnail-bg" style="background-image: url(<?php echo $url; ?>"
  43.                             href="<?php echo the_permalink(); ?>"></a>
  44.                     </div>
  45.                 </div>
  46.                 <div>
  47.                     <div class="blog-item_body">
  48.                         <h2 class="blog-item_title"><a href="<?php echo the_permalink(); ?>"><?php the_title(); ?></a>
  49.                         </h2>
  50.                         <ul class="blog-item_meta-info">
  51.                             <li class="blog-item_meta-author">
  52.                                 <a href="<?php echo get_author_posts_url($author_id).get_author_name($auth_id); ?>">
  53.                                     <span class="blog-item_meta-avatar">
  54.                                         <span style="background-image: url(<?php echo get_avatar_url($id); ?>)"></span>
  55.                                     </span><?php the_author(); ?>
  56.                                 </a>
  57.                             </li>
  58.                             <li><i class="fa fa-clock-o"></i><?php echo $date; ?></li>
  59.                         </ul>
  60.                         <div class="blog-item_content">
  61.                             <p><?php the_excerpt(); ?></p>
  62.                         </div>
  63.                         <a class="btn-primary"
  64.                             href="<?php echo the_permalink(); ?>"><?php the_field('read-more-text', get_option('page_for_posts')); ?></a>
  65.                     </div>
  66.                 </div>
  67.             </div>
  68.             <?php endwhile; ?>
  69.             <?php endif; ?>
  70.         </div>
  71.  
  72.         <div class="post-pagination">
  73.             <?php if(show_posts_nav($wp_query)) : ?>
  74.             <div class="blog-items_pagination">
  75.                 <?php bittersweet_pagination();  ?>
  76.             </div>
  77.             <?php endif; ?>
  78.         </div>
  79.  
  80.     </div>
  81. </div>
  82.  
  83. <div class="col-lg-3 col-md-4">
  84.     <?php get_template_part('template-parts/sidebar'); ?>
  85. </div>
  86.  
  87. <?php get_template_part('template-parts/newsletter'); ?>
  88. <?php get_footer();
  89.  
  90. ?>