ETFovac

Untitled

May 12th, 2015
305
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.87 KB | None | 0 0
  1. <section class="section section--drink">
  2.     <div class="container">
  3.  
  4.         <div class="row">
  5.  
  6.             <h1 class="section__title col-lg-6 col-md-6">
  7.                 <?php
  8.                 $category = get_category_by_slug('drinks');
  9.                 if($category) { ?>
  10.                     <a href="<?php echo get_category_link($category->term_id );?>"><?php echo get_category($category->term_id )->name;?></a>
  11.                 <?php }; ?>
  12.             </h1>
  13.  
  14.             <div class="section__link col-lg-6 col-md-6">
  15.                 <img src="<?php echo get_bloginfo('template_url') ?>/images/arrow-blue.jpg" alt="">
  16.                 <?php
  17.                 $category = get_category_by_slug('drinks');
  18.                 if($category) { ?>
  19.                     <a href="<?php echo get_category_link($category->term_id );?>">The city's best wine, beer & spirits</a>
  20.                 <?php }; ?>
  21.             </div>
  22.  
  23.  
  24.             <div class="left_articles col-lg-6 col-md-6">
  25.  
  26.             <?php
  27.  
  28.             $args = array(
  29.                 'posts_per_page' => '2',
  30.                 'order_by'       => 'post_date',
  31.                 'order'          => 'DESC',
  32.                 'post_type'      => 'post',
  33.                 'post_status'    => 'publish',
  34.                 'category_name'  => 'drinks'
  35.             );
  36.  
  37.             $posts = get_posts( $args );
  38.             $excluded = array();
  39.  
  40.             foreach( $posts as $key => $post ) {
  41.                 array_push($excluded, $post->ID);
  42.  
  43.                 if ( $key == 0 ) { ?>
  44.  
  45.                 <article class="first cf">
  46.                
  47.                     <div class="article__image">
  48.                         <a href="<?php the_permalink(); ?>" class="section__image">
  49.                             <?php the_post_thumbnail( 'drink-big' ); ?>
  50.                         </a>
  51.                     </div>
  52.  
  53.                     <div class="article__info">
  54.                         <div class="category">
  55.                             <?php
  56.                             $category = get_the_category( $post->ID);
  57.                             if(!empty($category)){ ?>
  58.                                 <a href="<?php echo get_category_link($category[0]->term_id );?>"><?php echo $category[0]->cat_name; ?></a>
  59.                             <?php } ?>
  60.                         </div>
  61.                         <div>
  62.                             <?php the_title( '<h1 class="article__title"><a href="' . esc_url( get_permalink() ) . '" >', '</a></h1>' ); ?>
  63.                         </div>
  64.                         <p>
  65.                         <?php
  66.                         $field = get_field('post_intro', $post->ID);
  67.                         $post_intro = '';
  68.                         if (!empty($field)) {
  69.                             $post_intro = $field;
  70.                         }
  71.                         //echo $post_intro;
  72.                         ?>
  73.                         <?php echo post_string_short($post_intro, '', 20); ?>
  74.                         </p>
  75.                     </div>
  76.                 </article>
  77.  
  78.                 <?php } else { ?>
  79.  
  80.                 <article class="second cf">
  81.                     <div class="article__info">
  82.                         <div class="category">
  83.                             <?php
  84.                             $category = get_the_category( $post->ID);
  85.                             if(!empty($category)){ ?>
  86.                                 <a href="<?php echo get_category_link($category[0]->term_id );?>"><?php echo $category[0]->cat_name; ?></a>
  87.                             <?php } ?>
  88.                         </div>
  89.                         <div>
  90.                             <?php the_title( '<h1 class="article__title"><a href="' . esc_url( get_permalink() ) . '" >', '</a></h1>' ); ?>
  91.                         </div>
  92.                         <p>
  93.                         <?php
  94.                         $field = get_field('post_intro', $post->ID);
  95.                         $post_intro = '';
  96.                         if (!empty($field)) {
  97.                             $post_intro = $field;
  98.                         }
  99.                         //echo $post_intro;
  100.                         ?>
  101.                         <?php echo post_string_short($post_intro, '', 10); ?>
  102.                         </p>
  103.                     </div>
  104.                 </article>
  105.  
  106.                 <?php }
  107.  
  108.             } ?>
  109.                
  110.             </div>
  111.  
  112.  
  113.  
  114.             <div class="right_articles col-lg-6 col-md-6">
  115.  
  116.             <?php
  117.  
  118.             $posts = get_posts_normal_and_sponsored ('drinks', 1, 1, 0, $excluded);
  119.  
  120.             foreach( $posts as $key => $post ) {
  121.                 $sponsored_class = '';
  122.                 $span_sponsored = '';
  123.                 if ($post->is_sponsored != '') {
  124.                   $sponsored_class = 'sponsored';
  125.                   $span_sponsored = '<span>Sponsored</span>';
  126.                 }
  127.  
  128.                 ?>
  129.  
  130.                 <article class="cf <?php echo $sponsored_class;?>">
  131.                
  132.                     <div class="article__image fl">
  133.                         <a href="<?php the_permalink(); ?>" class="section__image">
  134.                             <?php echo $span_sponsored;?>
  135.                             <?php the_post_thumbnail( 'drink-small' ); ?>
  136.                         </a>
  137.                     </div>
  138.  
  139.                     <div class="article__info fl">
  140.                         <div class="category">
  141.                             <?php
  142.                             $category = get_the_category( $post->ID);
  143.                             if(!empty($category)){ ?>
  144.                                 <a href="<?php echo get_category_link($category[0]->term_id );?>"><?php echo $category[0]->cat_name; ?></a>
  145.                             <?php } ?>
  146.                         </div>
  147.                         <div>
  148.                             <?php the_title( '<h1 class="article__title"><a href="' . esc_url( get_permalink() ) . '" >', '</a></h1>' ); ?>
  149.                         </div>
  150.                         <p>
  151.                         <?php
  152.                         $field = get_field('post_intro', $post->ID);
  153.                         $post_intro = '';
  154.                         if (!empty($field)) {
  155.                             $post_intro = $field;
  156.                         }
  157.                         //echo $post_intro;
  158.                         ?>
  159.                         <?php echo post_string_short($post_intro, '', 10); ?>
  160.                         </p>
  161.                     </div>
  162.                 </article>
  163.  
  164.             <?php } ?>
  165.                
  166.             </div>
  167.  
  168.         </div>
  169.  
  170.  
  171.         <div class="row">
  172.             <div class="col-lg-12 col-md-12">
  173.                 <?php
  174.                 $category = get_category_by_slug('drinks');
  175.                 if($category) { ?>
  176.                     <a class="seemore" href="<?php echo get_category_link($category->term_id );?>">read more
  177.                         <img src="<?php echo get_bloginfo('template_url') ?>/images/img-seemore-blue.jpg" alt="">
  178.                     </a>
  179.                     <?php }; ?>
  180.             </div>
  181.         </div>
  182.  
  183.     </div>
  184. </section>
Advertisement
Add Comment
Please, Sign In to add comment