<?php
/**
 * Theme Name: EduCare
 * Theme URI: http://demo.com/educare
 * Author: demo.com
 * Author URI: http://demo.com
 * Description: Themes Is WordPress Theme Market
 * @package eschool
 */
 global $codedokan;
 ?> 
 
 
 <?php 
								$count_posts = wp_count_posts( 'courses' )->publish;
								if ($count_posts == 0){
									get_template_part( 'template-parts/html/course' );
								}else{
								?>
								
                    <!--=========codedokan==============
                        Course section Start
                    =============codedokan=============-->    
        <section class="course-section">
            <div class="container">
			<?php $course_title = $codedokan['our_course']; if($course_title) { ?>
			
                <div class="row">
                    <div class="col-lg-12 col-md-12">
                        <div class="sec-content">
                            <h1 class="sec-title">
                                <?php echo $course_title; ?>
                            </h1>
                            <div class="secIcon">
                                <img src="<?php echo get_template_directory_uri(); ?>/assets/images/heading-line.png" alt="">
                            </div>
                        </div>
                    </div>
                </div><!--End row-->
			<?php } ?>
                <div class="row">
                    <div class="col-lg-12">
                        <div class="coures-active owl-carousel">
                            
							<?php $cat_id = $codedokan['coursescat'];
					if($cat_id == 0) { ?>
					<?php
									$how_post = $codedokan['how_course'];
									$code_dokan = new WP_Query(array(
										'post_type' => 'courses',
										'offset'     =>0,
										'posts_per_page' => $how_post,
									));
									while($code_dokan->have_posts()) : $code_dokan->the_post(); ?>
									
									
							<div class="course-wrpp">
							<?php $image = wp_get_attachment_url( get_post_thumbnail_id($post->ID)); if($image){?>
                                <figure class="course-image"><!--Image Crop: w:800px H:475px-->
                                    <img src="<?php echo $image; ?>" alt="">
                                </figure>
								<?php } ?>
                                <h4 class="course-title">
                                    <a href="<?php the_permalink()?>"><?php the_title() ?> </a>	
                                </h4>
                                <div class="course-priceContent">
								<?php $course_price = get_post_meta(get_the_ID(),'course_price', true); if($course_price){ ?>
                                    <div class="course-price">
                                        <?php echo $course_price; ?>
                                    </div>
								<?php } ?>

                                    <?php $more = get_post_meta(get_the_ID(),'courses_more_text', true); if($more){ ?>
									<div class="course-btn">
                                        <a href="<?php the_permalink()?>"> <?php echo $more; ?> </a>
                                    </div>
									<?php } ?>
                                </div><!--End Price-->
                            </div><!--End wrpp-->


<?php endwhile;?>
					<?php }else{
					?>

                    <?php
								$term = get_term_by( 'id', $cat_id, 'coursescat' );
                                $cat_name = $term->name;    
                                $cat_slug = $term->slug; 
								$how_post = $codedokan['how_course'];
								
							?>
							<?php   
									$args = array( 
										'post_type' => 'courses',
										'posts_per_page' => $how_post,
										  'tax_query' => array(
											'relation' => 'OR',     
											array(
												'taxonomy' => 'coursescat',
												'field'    => 'slug',
												'terms'    => $cat_slug,
											),
								
											) 
										); 
									$loop = new WP_Query( $args );
									while ( $loop->have_posts() ) : $loop->the_post(); ?>	
									
									<div class="course-wrpp">
							<?php $image = wp_get_attachment_url( get_post_thumbnail_id($post->ID)); if($image){?>
                                <figure class="course-image"><!--Image Crop: w:800px H:475px-->
                                    <img src="<?php echo $image; ?>" alt="">
                                </figure>
								<?php } ?>
                                <h4 class="course-title">
                                    <a href="<?php the_permalink()?>"><?php the_title() ?> </a>	
                                </h4>
                                <div class="course-priceContent">
								<?php $course_price = get_post_meta(get_the_ID(),'course_price', true); if($course_price){ ?>
                                    <div class="course-price">
                                        <?php echo $course_price; ?>
                                    </div>
								<?php } ?>

                                    <?php $more = get_post_meta(get_the_ID(),'courses_more_text', true); if($more){ ?>
									<div class="course-btn">
                                        <a href="<?php the_permalink()?>"> <?php echo $more; ?>  </a>
                                    </div>
									<?php } ?>
                                </div><!--End Price-->
                            </div><!--End wrpp-->
									
									
									 <?php endwhile; wp_reset_query(); ?> 
					<?php } ?>
          

                        </div><!--End owl-carousel-->
                    </div><!--End col-12-->
                </div><!--Edn row-->
            </div><!--End container-->
        </section><!--End section-->
            
     <?php } ?>           
                <!--=========codedokan==============
                    Course section End
                =============codedokan=============-->    

