Advertisement
Guest User

Untitled

a guest
Oct 21st, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.38 KB | None | 0 0
  1. <?php
  2. // Add the home blog custom loop
  3. add_action( 'beans_main_append_markup', 'hg_home_posts_loop' );
  4.  
  5. function hg_home_posts_loop() { ?>
  6.  
  7.   <?php query_posts('showposts=1&post_type=post'); ?>
  8.  
  9.   <div class="tm-posts-wrap">
  10.     <h2 class="tm-double-border uk-text-center"><span>Recent Blog Posts</span></h2>
  11.     <div class="uk-grid uk-grid-collapse">
  12.       <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  13.         <?php
  14.  
  15.           $thumb_id = get_post_thumbnail_id();
  16.           $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
  17.           $thumb_width = $thumb_url_array[1];
  18.           $thumb_height = $thumb_url_array[2];
  19.  
  20.           $resized_src = beans_edit_image( $thumb_url_array[0], array(
  21.             'resize' => array( 720, 500, array( 'center', 'top' ) )
  22.           ) );
  23.         ?>
  24.         <div class="uk-width-1-1 uk-width-medium-2-3">
  25.           <div class="tm-featured-post">
  26.             <figure class="uk-overlay">
  27.               <img src="<?php echo $resized_src; ?>" />
  28.               <figcaption class="uk-overlay-panel uk-overlay-bottom uk-overlay-background uk-contrast uk-width-3-4">
  29.                 <h3 class="uk-text-uppercase"><?php the_title() ;?></h3>
  30.                 <?php echo wp_trim_words( get_the_excerpt(), 140, '...' ); ?> <a href="<?php echo get_the_permalink(); ?>">read more</a>
  31.               </figcaption>
  32.               <a class="uk-position-cover" href="<?php echo get_permalink(); ?>" title="<?php esc_attr( get_the_title() ); ?>"></a>
  33.             </figure>
  34.           </div>
  35.         </div>
  36.       <?php endwhile; else: ?>
  37.  
  38.         <p>Sorry, there are no posts to display</p>
  39.  
  40.       <?php endif; ?>
  41.  
  42.       <?php rewind_posts(); ?>
  43.  
  44.       <?php query_posts('showposts=2&offset=1&post_type=post'); ?>
  45.       <div class="uk-width-1-1 uk-width-medium-1-3">
  46.         <div>
  47.           <div class="uk-grid uk-grid-collapse">
  48.               <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  49.                 <?php
  50.  
  51.                   $thumb_id = get_post_thumbnail_id();
  52.                   $thumb_url_array = wp_get_attachment_image_src($thumb_id, 'full', true);
  53.                   $thumb_width = $thumb_url_array[1];
  54.                   $thumb_height = $thumb_url_array[2];
  55.  
  56.                   $resized_src = beans_edit_image( $thumb_url_array[0], array(
  57.                     'resize' => array( 400, 250, array( 'center', 'top' ) )
  58.                   ) );
  59.                 ?>
  60.                   <div class="tm-sub-item uk-width-small-1-2 uk-width-medium-1-1">
  61.                     <figure class="uk-overlay uk-animation-hover">
  62.                       <img src="<?php echo $resized_src; ?>" />
  63.                       <figcaption class="uk-overlay-panel uk-overlay-bottom uk-overlay-background uk-animation-slide-right">
  64.                         <h3 class="uk-text-uppercase"><a href="<?php echo get_the_permalink(); ?>"><?php echo wp_trim_words( get_the_title(), 4, '...' ); ?></a></h3>
  65.                       </figcaption>
  66.                       <a class="uk-position-cover" href="<?php echo get_permalink(); ?>" title="<?php esc_attr( get_the_title() ); ?>"></a>
  67.                     </figure>
  68.                 </div>
  69.               <?php endwhile; ?>
  70.           </div>
  71.         </div>
  72.     </div>
  73.  
  74.     <?php else: ?>
  75.  
  76.         <p>Sorry, there are no posts to display</p>
  77.  
  78.       <?php endif; ?>
  79.     </div>
  80.   </div>
  81. <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement