<?php
/*services*/
function ctserviceShortCode($pageId = null, $isCustomizer = false, $i = null) {
    ob_start();
    $args = array('post_type' => 'our-services');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('lz_fitness_ct_service_npp_count',8);  
    //$lz_fitness_ct_service_icon1 = get_theme_mod('lz_fitness_ct_service_icon1'.$i);
    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
        case 2:
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
        case 3:
        case 5:
        case 6: 
        case 9:
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
        case 4: 
        case 7:
        case 8:
        case 10:  
        case 11:
        case 12:        
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
        default: 
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
    }
    $icons = array(1=>'heart', 2=>'star', 3=>'flash', 4=>'bell',5=>'heart', 6=>'star', 7=>'flash', 8=>'bell');  
    // }
    $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();
            ?>
            <div class="item">
                <div class="our-homepage-services">
                    <div class="services-front">
                        <?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(); ?>" />

                        <h3> <?php the_title(); ?></h3>
                        <p><?php 
                        if(has_excerpt()){
                            echo get_the_excerpt();
                        }else{
                            echo lz_fitness_excerpt( get_the_content() , 110 );
                        }
                        ?></p>
                        <?php
                            $homepageservicesbutton = get_theme_mod('lz_fitness_homepageservices_txt', 'READ MORE'); 
                        ?>
                        <?php if( get_theme_mod('homepageservices_button_display','show' ) == 'show') :
                            ?>  
                            <a href="<?php the_permalink(); ?>" class="site-button"><?php echo ($homepageservicesbutton );  ?></a>
                        <?php endif ?>
                    </div>
                </div>
            
            <!-- </div>   --> 
<script>
        jQuery.noConflict();
        $(function(){
            function timelineinnHeight(){
                var ht = 0;
                $('#innerpage-box .timelineinn').each(function(i){
                    var tHt = $(this).height();
                    if(ht<tHt){
                        ht=tHt;
                    }
                });
                $('#innerpage-box .timelineinn').height(ht+'px');
            }
            timelineinnHeight();
        });
        $( window ).resize(function(){
            timelineinnHeight();
        });
    </script>
        <!-- For Services Innerpage -->

</div>
    <?php
endwhile;
$text = ob_get_contents();
ob_clean();
endif;
wp_reset_postdata();
return $text;
}


// ==========================
function serviceInnerpageShortCode($pageId = null, $isCustomizer = false, $i = null) {
    ob_start();
    $args = array('post_type' => 'our-services');
    if (!empty($pageId)) {
        $args['page_id'] = absint($pageId);
    }
    $args['posts_per_page'] = -1;
    $colCls = '';
    // if($isCustomizer == true){
    $cols = get_theme_mod('lz_fitness_ct_service_npp_count',8);  
    //$lz_fitness_ct_service_icon1 = get_theme_mod('lz_fitness_ct_service_icon1'.$i);
    ++$cols;
    switch ($cols) {
        case 1:
        $colCls = 'col-md-12 col-sm-12 col-xs-12';
        break;
        case 2: 
        $colCls = 'col-md-6 col-sm-6 col-xs-12';
        break;
        case 3:
        case 5:
        case 6:
        case 9:
        case 11:
        case 13:
        case 15:
        $colCls = 'col-md-4 col-sm-6 col-xs-12';
        break;
        default: 
        $colCls = 'col-md-4 col-sm-6 col-xs-12';
        break;
        }
  $icons = array(1=>'heart', 2=>'star', 3=>'flash', 4=>'bell',5=>'heart', 6=>'star', 7=>'flash', 8=>'bell');  
    // }
    $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();
            ?>
        <div class="<?php echo $colCls;?> single-subject-bx"> 
        <!-- <div class="item inser"> -->
             <div class=" timelineinn">
                <div class="timeline-content">
                    <div class="timeline-icon">
                       <?php
                       if (has_post_thumbnail()) {
                        $image_url = $lz_fitness_image[0];
                    } else {
                        $image_url = get_template_directory_uri() . '/images/project.jpg';
                    }
                    ?>                                                          
                        <img class="img-responsive" src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" />
                    </div>
                    <div class="inner-content">
                        <!-- <div class="textbx"></div> -->
                        <a href="<?php the_permalink(); ?>"><h2 class="title"><?php the_title(); ?></h2></a>
                        <p class="description">
                           <?php 
                           if(has_excerpt()){
                            echo get_the_excerpt();
                        }else{
                            echo lz_fitness_excerpt( get_the_content() , 150 );
                        }
                        ?>
                        </p>
                        <?php if( get_theme_mod('innerpageservices_button_display','show' ) == 'show') :
                            ?>  
                            <?php  
                            $innerpageservicesbutton = get_theme_mod('lz_fitness_innerpageservicesbutton_txt', 'Read More'); 
                            ?>
                            <a href="<?php the_permalink(); ?>" class="sitebutton"><?php echo ($innerpageservicesbutton );  ?> <i class="fa fa-long-arrow-right"></i></a>
                        <?php endif ?>
                    </div>
                </div> 
            </div>

        <script>
                jQuery.noConflict();
                $(function(){
                    function singlesubjectHeight(){
                        var ht = 0;
                        $('#innerpage-box .single-subject').each(function(i){
                            var tHt = $(this).height();
                            if(ht<tHt){
                                ht=tHt;
                            }
                        });
                        $('#innerpage-box .single-subject').height(ht+'px');
                    }
                    singlesubjectHeight();
                });
                $( window ).resize(function(){
                    singlesubjectHeight();
                });
            </script>   
 </div> 

   
                <?php
            endwhile;
            $text = ob_get_contents();
            ob_clean();
        endif;
        wp_reset_postdata();
        return $text;
    }

add_shortcode('SERVICES', 'serviceInnerpageShortCode');
