<?php
/**
 *   Feature Section Functions And Definations
 *
 * @package Buzz_Agency
 */
function buzz_agency_feature_callback(){
	$feature_option = get_theme_mod('buzz_agency_homepage_setting_feature_option',0);
	if($feature_option == '1'): 
?>
		<section class="featured-section">
		    <div class="container">
		        <div class="featured-post-wrapper">
		        	<?php 
		        	for( $i = 1; $i < 4; $i++ ){
		        		$buzz_agency_featured_page_id = get_theme_mod('buzz_agency_featured_page'.$i); 
		        		$buzz_agency_featured_page_icon = get_theme_mod('buzz_agency_featured_page_icon'.$i);
						if($buzz_agency_featured_page_id){
							$args = array( 
			                    'page_id' => absint($buzz_agency_featured_page_id) 
			                    );
							$query = new WP_Query($args);

							if( $query->have_posts() ):
								
								while($query->have_posts()) : $query->the_post();
								?>
						            <article class="post os-animation  feature-<?php echo absint( $i ); ?>" data-os-animation="fadeInUp" data-os-animation-delay="1s">
						            	
						                <figure class="featuerd-image">
						                   <i class="<?php echo esc_attr($buzz_agency_featured_page_icon); ?>"></i>
						                </figure>
						                <div class="post-content">
						                    <header class="entry-header">
						                        <h3 class="entry-title"> <a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></h3>
						                    </header>
						                    <div class="entry-content">
						                        <p><?php echo esc_html(wp_trim_words(get_the_content(),35,'...')); ?></p>
						                    </div>
						                </div>
						                
						            </article>
						            
							<?php
								endwhile;
							endif;	
							wp_reset_postdata();
							}
							}
							?>    
		        </div>
		    </div>
		</section>	

	<?php endif;   ?>	
<?php
}
add_action('buzz_agency_feature_callback_action','buzz_agency_feature_callback');		
