HEX
Server: Apache
System: Linux web15f49.uni5.net 5.4.282-1.el8.elrepo.x86_64 #1 SMP Mon Aug 19 18:33:22 EDT 2024 x86_64
User: hzaluminio (728004)
PHP: 7.0.33
Disabled: apache_child_terminate,c99_buff_prepare,c99_sess_put,dl,eval,exec,leak,link,myshellexec,openlog,passthru,pclose,pcntl_exec,php_check_syntax,php_strip_whitespace,popen,posix_kill,posix_mkfifo,posix_setpgid,posix_setsid,posix_setuid,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,symlink,system,socket_listen,socket_create_listen,putenv
Upload Files
File: /home/hzaluminio/www/wp-content/themes/gaze/inc/content-portfolio-related.php
<?php 
	/**
	 * First, grab post terms.
	 */
	$terms = get_the_terms( $post->ID , 'portfolio_category', 'string');
	
	/**
	 * Return if this post has no terms
	 */
	if(!( $terms ))
		return false;
	
	/**
	 * Now we know that we definitely have terms to work with, build and array of term id's
	 */	
	$term_ids = array_values( wp_list_pluck( $terms, 'term_id' ) );
	
	/**
	 * Set our arguments for finding related posts
	 */
	$related_args = array(
		'post_type' => 'portfolio',
		'tax_query' => array(
			array(
				 'taxonomy' => 'portfolio_category',
				 'field' => 'id',
				 'terms' => $term_ids,
				 'operator'=> 'IN'
			)
		),
		'posts_per_page' => '6',
		'ignore_sticky_posts' => 1,
		'orderby' => 'rand',
		'post__not_in'=> array(
			$post->ID
		)
	);
	
	/**
	 * Build the related posts query based on what we've grabbed above
	 */
	$related_query = new WP_Query( $related_args );
	
	if ( $related_query->have_posts() ) :
?>

<section class="section-wrap nopadding">
	<div class="container-fluid">
		
		<div class="row heading-row">
			<div class="col-md-6 col-md-offset-3 text-center">
				<h2 class="heading bottom-line uppercase"><?php esc_html_e( 'Related Works', 'gaze' ); ?></h2>
			</div>
		</div>

		<div class="row">
			<div id="works-slider" class="flickity-slider-wrap items-4 mfp-hover" data-autoplay="true" data-arrows="true" data-slidedots="false">
				<?php
					while ( $related_query->have_posts() ) : $related_query->the_post();
					
						/**
						 * Get blog posts by blog layout.
						 */
						get_template_part( 'loop/content-portfolio', 'carousel' );
					
					endwhile;	
				?>
			</div>
		</div>
		
	</div>
</section>

<?php endif;