<?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('ct_service_npp_count',2);  
      $ct_service_icon1 = get_theme_mod('ct_service_icon1'.$i);
   
    ++$cols;
    switch ($cols) {
        case 1:
            $colCls = 'col-md-12 col-sm-12';
            break;
            case 2:
            $colCls = 'col-md-6 col-sm-6';
            break;
            case 3:
            case 5:
            case 6: 
            case 9: 
            $colCls = 'col-md-4 col-sm-6';
            break;
            default: 
            $colCls = 'col-md-3 col-sm-6';
            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();
            $luzuk_image = wp_get_attachment_image_src(get_post_thumbnail_id(), 'total-service-thumb');
            $post = get_post();
            ?>
            <!-- <div class="row"> -->
                <div class="<?php echo $colCls; ?> serbox wow zoomIn services-sec hoverable">

                    <div class="serviceBox ov-hidden">
                           <i class="<?php echo $ct_service_icon1; ?>  tada midix infinite"></i> 
                        <div class="serviceBoximg">
                           <?php
                           if (has_post_thumbnail()) {
                            $image_url = $luzuk_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 class="hover-ripple right" style="opacity: 0.8;"></div>
                    </div>

                       <h3 class="title"><?php the_title(); ?></h3>
                             <div class="clearfix"></div>
                      <div class="data">
                        <?php

                        if(has_excerpt()){
                          echo get_the_excerpt();
                         }else{
                          echo luzuk_excerpt( get_the_content() , 70);
                         } 
                        ?>
                    </div>

                    <?php if( get_theme_mod('services_button_display','show' ) == 'show') :
                        ?>
                        <?php
                            $ct_service_page_id = get_theme_mod('ct_service_page'); 
                            $servicesbutn_text = get_theme_mod('servicesbutn_text', 'Read More');
                            ?>

                        <div class="servicesbtn"><a href="<?php the_permalink(); ?>"><?php echo $servicesbutn_text; ?></a></div>
                        <?php endif ?>

                    </div>

              
           <script>
            jQuery.noConflict();
            $(function(){
                function serboxHeight(){
                    var ht = 0;
                    $('#innerpage-box .serbox').each(function(i){
                        var tHt = $(this).height();
                        if(ht<tHt){
                            ht=tHt;
                        }
                    });
                    $('#innerpage-box .serbox').height(ht+'px');
                }
                serboxHeight();
            });
            $( window ).resize(function(){
                serboxHeight();
            });
        </script>
        <!-- for inner page -->
    </div>
    <?php
endwhile;
$text = ob_get_contents();
ob_clean();
endif;
wp_reset_postdata();
return $text;
}

//adding a shortcode for the team / trainer list 
    add_shortcode('SERVICES', 'ctserviceShortCode');
    


    