<?php
   
//Services shortcode  
function featuredShortCode($pageId = null, $isCustomizer = false, $i = null) {

    ob_start();

    $args = array('post_type' => 'feature');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('services_npp_count',7);  
    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-md-12 col-sm-12';
        break;
        case 2:
        case 3:
        case 4: 
        case 5:
        case 6: 
        case 7: 
        case 8: 
        case 9:
        case 10:
        case 11:
        case 12: 
        case 13: 
        case 14: 
        case 15:
        case 16: 

        $colCls = 'col-md-3 col-sm-6';
        break;

        default: 
        $colCls = 'col-md-4 col-sm-6';
        break;
    }
    // }
    $text = '';
    $query = new WP_Query($args);
    if ($query->have_posts()):
        $postN = 0;

        while ($query->have_posts()) : $query->the_post();
            $lz_fitness_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-service-thumb');
            $post = get_post();
            if (($postN % 4) == 0 && $isCustomizer == false) {
                $homepageservicesbutton = get_theme_mod('homepageservices_buttxt', 'Read More');
                ?>
                <div class="clearfix paddingBot20"></div>
            </div>
            <div class="row">
                <?php
            }
            ++$postN;

            ?>
            <div class="row">
                <div class="<?php echo $colCls; ?> padding10">
                    <div class="services-post">
                         <a href="<?php the_permalink(); ?>">
                        <div class="service_img">
                            <?php
                            if (has_post_thumbnail()) {
                                $image_url = $lz_fitness_image[0];
                            } else {
                                $image_url = get_template_directory_uri() . '/images/project.jpg';
                            }
                            ?>                                                          
                            <img class="secondry-bg img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                        </div>
                    </a>
                        <div class="services-data">  

                            <h3 class="post-title"> <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>                     

                            <p class="description"><?php
                            if (has_excerpt()) {
                                echo get_the_excerpt();
                            } else {
                                echo lz_fitness_excerpt(get_the_content(), 130);
                            }
                            ?>
                        </p>
                        <?php
                            $homepageservicesbutton = get_theme_mod('homepageservices_buttxt', 'Read More'); 
                            ?>
                        <?php if( get_theme_mod('servicesall_button_display','show' ) == 'show') :
                            ?>
                        <button><a href="<?php echo esc_url(get_permalink()); ?>"><?php echo ($homepageservicesbutton );  ?><i class="fa fa-arrow-right"></i> </a></button>
                       <?php endif ?>

                   </div>


               </div>
           </div>
           <?php
       endwhile;
       $text = ob_get_contents();
       ob_clean();
   endif;
   wp_reset_postdata();
   return $text;
}
add_shortcode('SERVICES', 'featuredShortCode');
