HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux WebLive 5.15.0-79-generic #86-Ubuntu SMP Mon Jul 10 16:07:21 UTC 2023 x86_64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/html/wptrinityconsulting/wp-content/themes/finbuzz/inc/modules/rt-gallery-related.php
<?php
/**
 * @author  RadiusTheme
 * @since   1.0
 * @version 1.0
 */

if( ! function_exists( 'finbuzz_related_gallery' )){
	
	function finbuzz_related_gallery(){
		$post_id = get_the_id();	
		$number_of_avail_post = '';
		$current_post = array( $post_id );
		$title_length = FinbuzzTheme::$options['gallery_related_port_title_limit'] ? FinbuzzTheme::$options['gallery_related_port_title_limit'] : '';
		$related_post_number = FinbuzzTheme::$options['gallery_related_port_number'];
		
		$content 	= get_the_content();
		$content 	= apply_filters( 'the_content', $content );
		$content 	= wp_trim_words( get_the_excerpt(), FinbuzzTheme::$options['gallery_arexcerpt_limit'], '' );
		
		$port_related_title  = get_post_meta( get_the_ID(), 'gallery_port_related_title', true );

		# Making ready to the Query ...
		$query_type = FinbuzzTheme::$options['related_post_query'];

		$args = array(
			'post_type'				 => 'finbuzz_gallery',
			'post__not_in'           => $current_post,
			'posts_per_page'         => $related_post_number,
			'no_found_rows'          => true,
			'post_status'            => 'publish',
			'ignore_sticky_posts'    => true,
			'update_post_term_cache' => false,
		);

	

		# Get related posts by categories ----------
			$terms = get_the_terms( $post_id, 'finbuzz_gallery_category' );
			if($terms){
				if ( $terms && ! is_wp_error( $terms ) ) {
			 
					$port_cat_links = array();
				 
					foreach ( $terms as $term ) {
						$port_cat_links[] = $term->term_id;
					}
				}
				
				$args['tax_query'] = array (
					array (
						'taxonomy' => 'finbuzz_gallery_category',
						'field'    => 'ID',
						'terms'    => $port_cat_links,
					)
				);
			}
			
		# Get the posts ----------
		$related_query = new wp_query( $args );
		
		
		$count_post = $related_query->post_count;
		if ( $count_post < 4 ) {
			$number_of_avail_post = false;
		} else {
			$number_of_avail_post = true;
		}

		$swiper_data=array(
			'slidesPerView' 	=>2,
			'centeredSlides'	=>false,
			'loop'				=>true,
			'spaceBetween'		=>20,
			'slideToClickedSlide' =>true,
			'slidesPerGroup' => 1,
			'autoplay'				=>array(
				'delay'  => 1,
			),
			'speed'      =>500,
			'breakpoints' =>array(
				'0'    =>array('slidesPerView' =>1),
				'576'    =>array('slidesPerView' =>2),
				'768'    =>array('slidesPerView' =>2),
				'992'    =>array('slidesPerView' =>2),
				'1200'    =>array('slidesPerView' =>3),				
				'1600'    =>array('slidesPerView' =>3)				
			),
			'auto'   =>false
		);

		$swiper_data = json_encode( $swiper_data );
		
		if( $related_query->have_posts() ) { ?>
		
		<div class="gallery-default zoom-gallery gallery-multi-layout-1  rt-related-gallery">
			<div class="rt-related-slider" data-xld = '<?php echo esc_attr($swiper_data) ;?>'>
				<div class="section-title">
					<?php if ( FinbuzzTheme::$options['port_related_title'] ) { ?>
						<h3 class="related-title"><?php echo wp_kses( FinbuzzTheme::$options['gallery_port_related_title'] , 'alltext_allow' );?>
						</h3>
					<?php } ?>
					<?php if ( $count_post > 3 ){ ?>
						<div class="swiper-button">
							<div class="swiper-button-prev"><i class="fas fa-chevron-left"></i></div>
							<div class="swiper-button-next"><i class="fas fa-chevron-right"></i></div>
						</div>
					<?php } ?>
				</div>
				<div class="swiper-wrapper">
					<?php
						while ( $related_query->have_posts() ) {
						$related_query->the_post();
						$trimmed_title = wp_trim_words( get_the_title(), $title_length, '' );
					?>
						<div class="swiper-slide">
							<div class="rtin-item">						
								<div class="rtin-figure">
									<a href="<?php the_permalink(); ?>">
										<?php
											$id = get_the_ID();
											$thumbnail = false;
											if ( has_post_thumbnail() ){
												$post_thumbnail_id = get_post_thumbnail_id( $id );
												$image_attributes = wp_get_attachment_image_src( $post_thumbnail_id , 'finbuzz-size7'  );
												if ( $image_attributes ) : ?>
													<img src="<?php echo esc_attr( $image_attributes[0] ); ?>" width="<?php echo esc_attr( $image_attributes[1] ); ?>" height="<?php echo esc_attr( $image_attributes[2] ); ?>" alt="<?php the_title_attribute(array('echo'=> false)) ?>" />
												<?php endif; 
											} else {
												$thumbnail = '<img class="" src="'.FINBUZZ_IMG_URL.'noimage_370X328.jpg" alt="'. the_title_attribute(array('echo'=> false)) .'">';
											}
											echo wp_kses( $thumbnail , 'alltext_allow' );
										?>
									</a>
									<div class="rtin-content">					
										<h3><a href="<?php echo wp_get_attachment_url( get_post_thumbnail_id() ); ?>" class="finbuzz-popup-zoom img-popup-icon"><span><?php echo wp_kses( $trimmed_title , 'alltext_allow' ); ?></span></a></h3>
										<?php if ( FinbuzzTheme::$options['gallery_related_port_cat'] ) { ?>
										<div class="rtin-cat"><?php
											$i = 1;
											$term_lists = get_the_terms( get_the_ID(), 'finbuzz_gallery_category' );
											foreach ( $term_lists as $term_list ){ 
											$link = get_term_link( $term_list->term_id, 'finbuzz_gallery_category' ); ?><?php if ( $i > 1 ){ echo esc_html( ', ' ); } ?><a href="<?php echo esc_url( $link ); ?>"><?php echo esc_html( $term_list->name ); ?></a><?php $i++; } ?></div>
										<?php } ?>
										<?php if ( FinbuzzTheme::$options['gallery_show_related_port_content'] ) { ?>
											<p><span><?php echo wp_kses( $content , 'alltext_allow' ); ?></span></p>
										<?php } ?>
										<?php if(FinbuzzTheme::$options['gallery_ar_link']){?>
											<div class="item-button">
												<a href="<?php the_permalink();?>" class="gallery-btn">+</a>
											</div>
										<?php } ?>
									</div>
								</div>
							</div>
						</div>
					<?php } ?>
			   </div>
			</div>
		</div>
		<?php }
		wp_reset_postdata();
	}
}
?>