Mastek Resource Page for filter data

PHOTO EMBED

Tue Sep 12 2023 07:51:58 GMT+0000 (Coordinated Universal Time)

Saved by @gshailesh27

<?php

/**
 * Template Name: Resources
 */

get_header();
?>

<?php //echo "<pre>"; print_r($the_cfc_field);exit;?>
<div class="pageWrapper">

		<div class="stickyAnchor" id="sticky-anchor"></div>

		<section class="bannerSection">

			<div class="swiper innerBannerSwiper">

		    <div class="swiper-wrapper">
		    	
	        <div class="swiper-slide">
	        	<div class="banImgHolder"><img src="<?php the_cfc_field( 'resources-list-page','resources-list-page-banner'); ?>" class="w-100"></div>
	        	<div class="container slideText d-flex">
	        		<div class="align-self-center col col-md-9 col-xl-8">
	        			<h1 class="titleFont bigText"><?php the_cfc_field( 'resources-list-page','resources-list-page-banner-title'); ?></h1>
	        			<p><?php the_cfc_field( 'resources-list-page','resources-list-page-banner-sub-title'); ?></p>
		        	</div>
	        	</div>
	        </div>

	      </div>

	      <!-- <div class="swiper-button-prev heroNavBtns heroPrev"></div>
	      <div class="swiper-button-next heroNavBtns heroNext"></div> -->

		    <div class="swiper-pagination slideBullets"></div>
				
			</div>
			
		</section>


		<section class="pt-5 filterSection">
			<div class="container">

				<div class="btn filterBtn" data-bs-toggle="collapse" href="#resourceFilters" role="button" aria-expanded="true" aria-controls="resourceFilters"><strong>Filters </strong></div>

				<div class="collapse show" id="resourceFilters">

					<div class="w-100 p-3 filterWrapper">

						<div class="row">
							<div class="col-sm-auto"><strong class="blueText mt-2 d-inline-block">Format : </strong></div>
							<div class="col filtersList">
								<div class="filter-custom-taxonomy">
										<?php
										$terms = get_terms( 'resources-category' );
										foreach ( $terms as $term ) : 
										$class99='';
										if($_GET['cat']==$term->slug) $class99='active';?>
										<a href="/resources-list/page/1/?getby=cat&cat=<?php echo esc_attr( $term->slug ); ?>" class="btn rounded-pill <?php echo $class99; ?>">
												<?php echo esc_html( $term->name ); ?>
										</a>
										<?php endforeach; ?>
								</div>
							</div>
						</div>

						<hr class="my-2">

					<div class="row">
							<div class="col-sm-auto"><strong class="blueText mt-2 d-inline-block">Service : </strong></div>
							<div class="col filtersList">
								<div class="filter-custom-taxonomy">
										<?php
										$terms = get_terms( 'resourceservicetexo' );
										
										foreach ( $terms as $term ) :
										  $class90='';
										if($_GET['taxo']==$term->slug) $class90='active';
										if(isset($_GET['cat']))
										{?>
										<a href="https://<?php echo $_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI'] ?>&taxo=<?php echo $term->slug ?>" class="btn rounded-pill <?php echo $class90; ?>">
										<?php }
										else
										{ ?>
									<a href="https://<?php echo $_SERVER['HTTP_HOST'].'/'.$_SERVER['REQUEST_URI'] ?>?taxo=<?php echo $term->slug ?>" class="btn rounded-pill <?php echo $class90; ?>">
									
									
										<?php } ?>
												<?php echo esc_html( $term->name ); ?>
										</a>
										<?php endforeach; ?>
								</div>
							</div>
						</div>

					</div>




					
				</div>

			</div>
		</section>


		<section class="py-5">
			<div class="container">


				<div class="row justify-content-center g-5 insightList row-cols-lg-3 row-cols-md-2 row-cols-1 mb-5">
				
				
				
				<?php 
						
							$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
							$taxo='';
							$category99='';
							if(isset($_GET['cat']) || isset($_GET['taxo']))
							{
							$category99=$_GET['cat'];
							$taxo=$_GET['taxo'];
							$args = array(  
								'post_type' => 'resources',
								'paged' => $paged,
								'post_status' => 'publish',
								'posts_per_page' => 12, 
								'orderby' => 'title', 
								'resources-category' => $category99,
								'resourceservicetexo' => $taxo,
								'order' => 'ASC', 
								'post__not_in' => array(get_the_ID()),
							);
							}
							else
							{
								$args = array(  
								'post_type' => 'resources',
								'paged' => $paged,
								'post_status' => 'publish',
								'posts_per_page' => 12, 
								'orderby' => 'title', 								
								'order' => 'ASC', 
								'post__not_in' => array(get_the_ID()),
							);		
								
								
							}
							

							$loop = new WP_Query( $args ); 
							//echo 'hello<pre>';print_r($loop);
							while ( $loop->have_posts() ) : $loop->the_post(); 
							//$term = get_term_by( 'slug', get_query_var('term'), get_query_var('resources-category') );
							$ancestors =  get_the_terms($post->ID, 'resources-category');
							$terms = $ancestors[0];
							//echo 'hello<pre>'; print_r($terms->name); echo '</pre>';
							
							?>
								
								
								<div class="animateThis slideTop">
									<div class="insightBox">
										<div class="insightImg">
										
										<?php if ($terms->slug == 'case_study'){ ?>
											<img src="<?php the_cfc_field( 'resources-main-content-section','resources-right-main-image'); ?>" class="w-100">
										<?php } else if($terms->slug == 'webinar') { ?>
											<img src="<?php the_cfc_field( 'resources-banner-data','resources-main-banner-image'); ?>" class="w-100">
										<?php } else if($terms->slug == 'video') { ?>	
											<img src="<?php the_cfc_field( 'resources-banner-data','resources-main-banner-image'); ?>" class="w-100">
										<?php } else if($terms->slug == 'whitepaper') { ?>
											<img src="<?php the_cfc_field( 'resources-banner-data','resources-main-banner-image'); ?>" class="w-100">
										<?php } else { ?>
											<img src="<?php the_cfc_field( 'resources-banner-data','resources-main-banner-image'); ?>" class="w-100">
										<?php } ?>
										
										
										
										
										
										
										</div>
										<div class="insightText">
											<div class="insightType mb-2">
											<?php if ($terms->slug == 'case_study'){ ?>
												<img src="<?php echo get_stylesheet_directory_uri();?>/images/icon_blog.png">
											<?php } else if($terms->slug == 'webinar') { ?>
												<img src="<?php echo get_stylesheet_directory_uri();?>/images/icon_webinar.png">
											<?php } else if($terms->slug == 'video') { ?>	
												<img src="<?php echo get_stylesheet_directory_uri();?>/images/icon_video.png">
											<?php } else if($terms->slug == 'whitepaper') { ?>
												<img src="<?php echo get_stylesheet_directory_uri();?>/images/icon_whitepaper.png">
											<?php } else { ?>
												<img src="<?php echo get_stylesheet_directory_uri();?>/images/icon_blog.png">
											<?php } ?>
											<!--<img src="images/icon_blog.png">--> <?php echo $terms->name; ?></div>
											<a href="<?php echo the_permalink(); ?>"><h2 class="insightTitle mb-2"><?php echo the_title(); ?></h2></a>
												
											<div class="short-content">
											<?php if ($terms->slug == 'case_study'){ ?>
												<?php the_cfc_field( 'resources-main-content-section','resources-left-content'); ?>
											<?php } else if($terms->slug == 'webinar') { ?>
												<?php the_cfc_field( 'resources-webinar-sec','webinar-content-data'); ?>
											<?php } else if($terms->slug == 'video') { ?>	
												<?php the_cfc_field( 'resources-video-section','video-resources-youtube-video-long-description'); ?>
											<?php } else if($terms->slug == 'whitepaper') { ?>
												<?php the_cfc_field( 'resources-webinar-sec','webinar-content-data'); ?>
											<?php } else { ?>
												<?php the_cfc_field( 'resources-main-content-section','resources-left-content'); ?>
											<?php } ?>
											</div>
											
											<a href="<?php echo the_permalink(); ?>" class="linkBtn"><?php the_cfc_field( 'resources-button-field','resources-button-text-field'); ?></a>
										</div>
									</div>
								</div>
								
								
						<?php	 endwhile;
						
						?>
						

				</div>
        
            <nav class="py-md-5">
						  <ul class="pagination justify-content-center">
							<?php
								$total_pages = $loop->max_num_pages;

								if ($total_pages > 1){

									$current_page = max(1, get_query_var('paged'));

									echo paginate_links(array(
								// 		'base' => get_pagenum_link(1) . '%_%',
							            'base'         => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
										'format' => '/page/%#%',
										'current' => $current_page,
										'total' => $total_pages,
										'prev_text'    => __('Prev'),
										'next_text'    => __('Next'),
									));
								}    
							wp_reset_postdata();
								?>
						  </ul>
						</nav>

			<!--	<nav class="py-md-5">
				  <ul class="pagination justify-content-center">
				    <li class="page-item disabled">
				      <a class="page-link">Prev</a>
				    </li>
				    <li class="page-item active"><a class="page-link" href="#">1</a></li>
				    <li class="page-item"><a class="page-link" href="#">2</a></li>
				    <li class="page-item"><a class="page-link" href="#">3</a></li>
				    <li class="page-item"><a class="page-link" href="#">4</a></li>
				    <li class="page-item"><a class="page-link" href="#">5</a></li>
				    <li class="page-item">
				      <a class="page-link" href="#">Next</a>
				    </li>
				  </ul>
				</nav>-->




			</div>
		</section>


	</div>


	<?php
	get_footer();
content_copyCOPY