<?php
get_header();
$term_slug                 = $wp_query->tax_query->queries[0]['terms'][0];
$practise_area_number_post = themesflat_get_opt( 'practise_area_number_post' ) ? themesflat_get_opt( 'practise_area_number_post' ) : 9;
$columns                   = themesflat_get_opt( 'practise_area_grid_columns' );
$columns_tb                = themesflat_get_opt( 'practise_area_grid_columns_tablet' );
$columns_mb                = themesflat_get_opt( 'practise_area_grid_columns_mobile' );
$paged                     = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;

$args              = array(
	'post_type'      => 'practise_area',
	'paged'          => $paged,
	'posts_per_page' => $practise_area_number_post,
);
$args['tax_query'] = array(
	array(
		'taxonomy' => 'practise_area_category',
		'field'    => 'slug',
		'terms'    => $term_slug
	),
);
$query             = new WP_Query( $args );
$item_classes      = themesflat_create_columns( $columns, $columns_tb, $columns_mb );
$sidebar           = themesflat_get_opt( 'practise_area_sidebar_list' );
$main_class        = 'col-12';
if ( themesflat_get_opt( 'practise_area_layout' ) == 'sidebar-left' || themesflat_get_opt( 'practise_area_layout' ) == 'sidebar-right' ) {
	if ( is_active_sidebar( $sidebar ) ) {
		$main_class = 'col-lg-9';
	}
}
$themesflat_paging_style = themesflat_get_opt( 'case_study_archive_pagination_style' );
?>
    <div class="themesflat-practise_area-taxonomy">
        <div class="container">
            <div class="wrap-content-area">
                <div class="row tf-wrap-content">
                    <div class="<?php echo esc_attr( $main_class ) ?> content-wrap tf-content-wrap">
                        <div id="primary" class="content-area">
                            <main id="main" class="main-content" role="main">

                                <div class="wrap-practise-area-post row column-<?php echo esc_attr( $columns ); ?>">
									<?php
									if ( $query->have_posts() ) {
										while ( $query->have_posts() ) : $query->the_post();
											global $post;
											$id                 = $post->ID;
											$services_post_icon = \Elementor\Addon_Elementor_Icon_manager_devoer::render_icon( themesflat_get_opt_elementor( 'services_post_icon' ), [ 'aria-hidden' => 'true' ] );
											?>
                                            <div class="item tf-services-style1 <?php echo esc_attr( $item_classes ) ?>">
                                                <div class="tf-services-post tf-services-post-<?php the_ID(); ?>">
													<?php if ( ! empty( $services_post_icon ) ): ?>
                                                        <div class="tf-service-icon">
															<?php echo $services_post_icon; ?>
                                                        </div>
													<?php endif; ?>
                                                    <div class="content">
														<?php $title = get_the_title();
														?>
                                                        <h2 class="title">
                                                            <a href="<?php echo get_the_permalink(); ?>"><?php echo esc_html( $title ) ?></a>
                                                        </h2>
                                                        <div class="desc"><?php echo wp_trim_words( get_the_content(), 8, '' ); ?></div>
                                                        <a href="<?php echo get_the_permalink(); ?>"
                                                           class="services-view-more">
                                                            <span class="text"><?php esc_html_e( 'Read more', 'themesflat' ) ?></span>
                                                            <span class="icon"><i class="fal fa-angle-double-right"></i></span>
                                                        </a>

                                                    </div>
                                                </div>
                                            </div>
										<?php
										endwhile;
									} else {
										get_template_part( 'template-parts/content', 'none' );
									}
									?>
                                </div>
								<?php
								themesflat_pagination_posttype( $query, '' );
								wp_reset_postdata();
								?>
                            </main><!-- #main -->
                        </div><!-- #primary -->
                    </div>
					<?php
					if ( themesflat_get_opt( 'practise_area_layout' ) == 'sidebar-left' || themesflat_get_opt( 'practise_area_layout' ) == 'sidebar-right' ) :
						get_sidebar();
					endif;
					?>
                </div>
            </div>
        </div>
    </div><!-- /.themesflat-practise_area-taxonomy -->
<?php get_footer(); ?>