<?php
/*
Template Name: Template - Blog Grid Full
*/
?>


<!-- Get Page Header
================================================== -->
<?php get_header(); ?>



<!-- Page Title Section
================================================== -->
<?php

	global $prof_default;
	$sentient_breadcrumb_text = __("You are here:  ","sentient");
	if(of_get_option('select_breadcrumb_position',$prof_default) == 'Right') {$breadcrumbPosition = '';} else {$breadcrumbPosition = 'breadcrumb-left';}
?>


<?php if(of_get_option('select_breadcrumb',$prof_default) == 'On'){ ?>
	<div class="homepage-container-design  homepage-container-design-top sentient-page-title-container">
		<div class="homepage-container-design-inner">
			<span class="sentient-page-title-text <?php echo $breadcrumbPosition; ?>"><?php echo get_the_title(); ?></span>
			<span class="sentient-page-breadcrumb-text <?php echo $breadcrumbPosition; ?>"><span class="sentient-page-breadcrumb-text-colored"><?php echo esc_attr($sentient_breadcrumb_text); ?></span><?php sentient_bread_crumbs(); ?></span>
		</div>
	</div>
<?php } ?>


<!-- Page Blog Body Start
================================================== -->
<div class="page-main-container page-main-container-blog page-main-container-blog-full-grid">
	 <div class="middle-container blog-middle-container blog-fullwidth-grid">
	 
			<?php
				if ($post->post_content == ""){
				
				} else {
			?>
				<div>
					<?php the_content(); ?>
				</div>
			<?php } ?>	 
	 
	 		<!-- Blog Categories
			================================================== -->
			<?php
				$terms = get_terms("category");  
				$count = count($terms);  
				$return_string = '';
				$allString = __("All" , "sentient");
				$return_string .='<div class="sentient-portfolio-five-col-filter sentient-portfolio-five-col-filter-internal"><ul  class="portfolio-filter-blog-full">';  
				$return_string .= '<li><button data-filter="*">' . $allString . '</button></li>';  
				if ( $count > 0 ){  
				  
					foreach ( $terms as $term ) {  
						if($term->name != 'Uncategorized' && $term->name != 'uncategorized'){
							$termname = strtolower($term->name);  
							$termname = str_replace(' ', '-', $termname);  
							$return_string .= '<li><button data-filter=".'.$termname.'">'.$term->name.'</button></li>';  
						}
					}  
				}  
				$return_string .= "</ul></div>";
				
				echo $return_string;		
			?>	 
			<div class="main-blog">				
				<div class="main-blog-for-sidebar">
				
				<!-- Loop Started
				================================================== -->				
				
				<?php if(have_posts()) : while(have_posts()) : the_post(); ?>						
					<div  class="main-blog">				
						<div id="SentientContainer" class="main-blog-for-sidebar cbp-so-section blog-fullwidth-grid-container isotope">			
						<?php
							$ProfPortfolioColCounter=1;
							$ProfPortfolioColIteration=1;
							$ProfPortfolioColNextIteration=0;
							$ProfPortfolioColIterationCompare = 1;	
						
							$temp = $wp_query;
							$wp_query= null;
							$wp_query = new WP_Query();
							if(get_post_meta(get_the_ID(), 'Category for Blogs Templates Only', true) != ''){
								$getpagecategory = get_post_meta(get_the_ID(), 'Category for Blogs Templates Only', true);
								$wp_query->query('posts_per_page=9'.'&paged='. $paged .'&category_name='.$getpagecategory);
							} else {
								$wp_query->query('posts_per_page=9'.'&paged='.$paged);
							}							
							/*$wp_query->query('posts_per_page=9'.'&paged='.$paged);*/
							while ($wp_query->have_posts()) : $wp_query->the_post();
						?>				
						<?php
							$terms = get_the_terms( get_the_ID() , 'category' );  
															  
							if ( $terms && ! is_wp_error( $terms ) ) :   
								$links = array();  

								foreach ( $terms as $term )   
								{  
									$links[] = $term->name;  
								}  
								$links = str_replace(' ', '-', $links);   
								$tax = join( " ", $links );       
							else :    
								$tax = '';    
							endif;
							
							$tax = strtolower($tax);
						?>							
						<div class="sentient-post <?php echo esc_attr($tax); ?>">
							<div <?php post_class(); ?>>
								<div class="prof-blog-col-thumb-box">
								
									<!-- Standard Post Format
									================================================== -->									

									<?php
										if ( get_post_format() == false && has_post_thumbnail()) {									
									?>
										<div class="blog-modern-left-box-thumb">								
											<a href="<?php echo esc_url(the_permalink()); ?>">
												<?php the_post_thumbnail(array(800,310)); ?>
												<i class="icon-pencil"></i>
											</a>								
										</div>
									<?php } ?>
									
									<!-- Video Post Format
									================================================== -->											
									<?php
										if ( has_post_format( 'video' ) && get_post_meta(get_the_ID(), 'Post Video URL', true) != '') {
									?>
										<div class="sentient-blog-listing-video-container">
											<iframe width="100%" height="240px" src="<?php echo esc_url(get_post_meta(get_the_ID(), 'Post Video URL', true)); ?>"></iframe>
										</div>
									<?php } ?>

									<!-- Gallery Post Format
									================================================== -->										
									<?php
										if ( has_post_format( 'gallery' ) && get_post_meta(get_the_ID(), 'Post Gallery Shortcode', true)!= '') { ?>
											<div class="sentient-blog-listing-gallery-container">
												<?php
													$newstring = 'gallery putin="blogs" ';
													$oldstring = get_post_meta(get_the_ID(), 'Post Gallery Shortcode', true);
													$gallerycode = str_replace("gallery",$newstring,$oldstring); 	
													echo  do_shortcode($gallerycode) . '<i class="icon-camera"></i>';
												?>
											</div>
									<?php } ?>
									
									<!-- Audio Post Format
									================================================== -->										
									<?php
										if ( has_post_format( 'audio' ) && get_post_meta(get_the_ID(), 'Post Audio Shortcode', true)!= '') { ?>
											<div class="sentient-blog-listing-audio-container">								
												<?php echo do_shortcode(get_post_meta(get_the_ID(), 'Post Audio Shortcode', true)) ;  ?>
											</div>
									<?php } ?>														
									
									<!-- Chat Post Format
									================================================== -->											
									<?php
										if ( has_post_format( 'chat' )) { ?>
											<div class="sentient-blog-listing-chat-container">
												<div class="sentient-blog-chat-quote-left"><i class="fa-quote-left"></i></div>
												<div class="sentient-blog-chat-quote-text">
													„<?php echo strip_shortcodes(wp_trim_words( get_the_content(), 23 )); ?>“
													<div class="sentient-blog-chat-quote-person"><?php echo '- ' . esc_attr(get_post_meta(get_the_ID(), 'Chat Person Name', true)); ?></div>
												</div>
												<div class="sentient-blog-chat-quote-right"><i class="fa-quote-right"></i></div>
											</div>
									<?php } ?>

									<!-- Blog Content Begin
									================================================== -->											
									<?php if ( !has_post_format( 'chat' )) {?>
									<div class="blog-modern-left-box-content">
										<?php 
											$all = __(' Comments', 'sentient');
											$one = __(' Comment', 'sentient');
										?>	
										<span class="prof-blog-col-title">
											<a href="<?php echo esc_url(the_permalink()); ?>"><?php the_title(); ?></a>
											<?php if ( has_post_format( 'link' )) {  ?>
												<span class="prof-blog-post-title-link"><a href="<?php echo esc_url(get_post_meta(get_the_ID(), 'Link Post URL Value', true)); ?>"><?php echo esc_url(get_post_meta(get_the_ID(), 'Link Post URL Value', true)); ?></a></span>
											<?php } ?>
										</span>
										
										<?php if (of_get_option('blog_functional',$prof_default) == 'On'){ ?>
											<div class="prof-blog-col-icon-container">
												<span class="blog-modern-thumb-text-date"><?php echo get_the_time('j') . ' ' . get_the_time('M') . ', ' . get_the_time('Y'); ?></span><span class="sentient-blog-normal-date-seperator">.</span>
												<span class="blog-modern-thumb-text-comments"><a href="<?php echo esc_url(get_comments_link(get_the_ID())); ?>"><?php comments_number( '0 ' . $all, '1 ' . $one, '% ' . $all); ?></a></span><span class="sentient-blog-normal-date-seperator">.</span>															
												<span class="blog-modern-thumb-text-author"><?php echo  _e('Posted By: ','sentient')?><a href="<?php echo esc_url(get_author_posts_url( get_the_author_meta( 'ID' ) )); ?>"><?php the_author(); ?></a></span>
											</div>										
										<?php } else { ?>
											<div class="prof-blog-col-icon-container">
												<span class="blog-modern-thumb-text-date"><?php echo get_the_time('j') . ' ' . get_the_time('M') . ', ' . get_the_time('Y'); ?></span><span class="sentient-blog-normal-date-seperator">.</span>
												<span class="blog-modern-thumb-text-comments"><?php comments_number( '0 ' . $all, '1 ' . $one, '% ' . $all); ?></span><span class="sentient-blog-normal-date-seperator">.</span>															
												<span class="blog-modern-thumb-text-author"><?php echo  _e('Posted By: ','sentient')?><?php the_author(); ?></span>
											</div>										
										<?php } ?>
										
										<div class="blog-modern-left-box-content-text">
											<?php echo strip_shortcodes(wp_trim_words( get_the_content(), 23 )); ?>
										</div>
										<div class="sentient-read-more-button">
											<a class="sentient-button sentient-button-blog-listing" href="<?php esc_url(the_permalink()); ?>"><?php _e( "Read More" , 'sentient') ?></a>
										</div>
									</div>
									
									<!-- Blog Content End
									================================================== -->										
									
									<?php } ?>
								</div>					
							</div>
						</div>
						<?php endwhile; ?>
						</div>
						
						<!-- Pagination Begin
						================================================== -->							
						<div id="page_nav" class="portfolio-pagination">
						<?php
							global $wp_query;

							$big = 999999999;

							echo paginate_links( array(
								'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
								'format' => '?paged=%#%',
								'current' => max( 1, get_query_var('paged') ),
								'total' => $wp_query->max_num_pages
							) );
						?>
						</div>
						<!-- Pagination End
						================================================== -->						
						
						<!-- Ajax Load More Button Begin
						================================================== -->							
						<div class="page-nav-button-load-container">
							<button id="page_nav_button_load" class="sentient-button"><?php _e("LOAD MORE POSTS" , "sentient"); ?></button>
							<div class="page-nav-button-loader"></div>
						</div>
						<!-- Ajax Load More Button End
						================================================== -->	
						
						<?php $wp_query = null; $wp_query = $temp;?>				
					</div>
				<?php endwhile; endif; ?>					
				</div>
			</div>
	 </div>
</div>
<!-- Page Blog Full Body End
================================================== -->



<!-- Get Page Footer
================================================== -->
<?php get_footer(); ?>