<?php
/**
 * Add List Block Posts
 *
 * @package Digital
 */

// Exit if accessed directly.
defined( 'ABSPATH' ) || exit;

function digital_blocktilesposts(){ ?>
<div class="row posttilesblock">

<div id="blockbig" class="col-sm-12 col-md-6">
<?php 
	$blockcate = absint(get_theme_mod('digital_blocktiles_cat'));
	$blockargs = array(
	'posts_per_page' => '1',
	'cat' => $blockcate,
	'ignore_sticky_posts' => true
	);
	$query = new WP_query ( $blockargs );
	if ( $query->have_posts() ) { ?>
	 
<?php while ( $query->have_posts() ) : $query->the_post(); /* start the loop */ ?>

<article id="post-<?php the_ID(); ?>" <?php post_class( 'first-post' ); ?>>
    <div class="thumbnailbig">
		<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
		<?php if ( has_post_thumbnail() ) {
			the_post_thumbnail('medium_large');
			} else { 
			?><img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/nothumb.jpg" />
			<?php } ?>  </a>
			
	<div class="container">
	<?php 
		
	$separate_meta = __( ' ', 'digital' );
	$categories_list = get_the_category_list( $separate_meta );		
		if ( 'post' === get_post_type() ) {			
				if ( $categories_list && digital_categorized_blog() ) {
							echo '<span class="categoryblock">'.wp_kses_post($categories_list) . '</span>';
						}
				
		} 
		?>
		<?php the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
	</div>
	</div>
 
</article><!-- #post-## -->
 
<?php // End the loop.
endwhile;
 
rewind_posts();
 
} ?>
</div>

<div id="blocksmall" class="col-sm-12 col-md-6">
	<div class="row">
<?php
$blockcate = absint(get_theme_mod('digital_blocktiles_cat'));
$args = array(
'posts_per_page' => '4',
'offset' => 1,
'cat' => $blockcate,
'ignore_sticky_posts' => true
);
$query = new WP_query ( $args );
if ( $query->have_posts() ) { 
while ( $query->have_posts() ) : $query->the_post(); ?>
 <div class="col-sm-6 col-md-6">
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
  
<div class="thumbnailsm"><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php if ( has_post_thumbnail() ) {the_post_thumbnail('medium');} else { ?><img src="<?php echo esc_url(get_template_directory_uri()); ?>/images/nothumb.jpg" alt="<?php the_title(); ?>" />
<?php } ?>  </a>

<div class="container">
	<?php 
		
	$separate_meta = __( ' ', 'digital' );
	$categories_list = get_the_category_list( $separate_meta );		
		if ( 'post' === get_post_type() ) {			
				if ( $categories_list && digital_categorized_blog() ) {
							echo '<span class="categoryblock">'.wp_kses_post($categories_list) . '</span>';
						}
				
		} 
		?>
		<?php the_title( sprintf( '<h3 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' ); ?>
	</div>
	</div>
 
     
             
   
</article><!-- #post-## -->
</div>
<?php // End the loop.
endwhile; }?>
</div>
</div>
</div>
<?php } 