Support

Account

Home Forums General Issues Filtering issues which remove images and filters on page Reply To: Filtering issues which remove images and filters on page

  • The checkboxes on the film page will only be shown if a film is assigned, so it prevents someone clicking filters and having no results.
    The code is in place as fallback OR in case you wish to adjust this behaviour.

    With regards to the similar/related films on the single film page, it depends on whether a film is assigned to one or many categories?

    Basically, you get the genres associated to the film you’re on, you can then run a query on the film post type and loop the results, something like:

    <?php
    $genres = get_the_terms( $post->ID, 'genres' ); 
    $genre = $genres[0];
    
    // print object from first genre
    #print_r($genre);
    
    // or get the genre name
    #echo $genre->name.' '.$genre->term_id;	
    	
    global $wp_query;
    $paged = get_query_var('paged') ? get_query_var('paged') : 1;
    
    $args = array( 
    	'posts_per_page'	=> 3,
    	'post_type'			=> 'film',
    	'paged'				=> $paged,
    	'fields'			=> 'ids',
    	'post__not_in'		=> array( $post->ID )
    );
    if($genre):
    $args['tax_query'] = array (
    	'relation' => 'OR', 
    
    	array(
    		'taxonomy'	=> 'genres',
    		'field'		=> 'term_id',
    		'terms'		=> $genre->term_id
    	), 
    );
    endif;
    
    $wp_query = new WP_Query($args);
    if ($wp_query->have_posts()) :
    ?>	
    
    <h3>Similar Films</h3>
    <ul>
    	<?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
    	<li><?php the_title(); ?></li>
    <?php endwhile;  ?>                       
    </ul>
    <?php endif; wp_reset_query(); ?>

    So basically, it you have multiples, it gets the first taxonomy only. You can of course adjust this but should help you out