????
| Current Path : /home2/morganrand/www/wp-content-bkp/themes/wanderfuls/partials/blog/ |
| Current File : /home2/morganrand/www/wp-content-bkp/themes/wanderfuls/partials/blog/blog-single-related.php |
<?php
/**
* Single related posts
*
* @package Wanderfuls WordPress Theme
* @subpackage Partials
* @version 3.0.0
*/
// Exit if accessed directly
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
// Return if disabled
if ( ! tb_get_mod( 'blog_related', true ) ) {
return;
}
// Number of columns for entries
$tb_columns = apply_filters( 'tb_related_blog_posts_columns', tb_get_mod( 'blog_related_columns', '3' ) );
// Create an array of current category ID's
$cats = wp_get_post_terms( get_the_ID(), 'category' );
$cats_ids = array();
foreach( $cats as $tb_related_cat ) {
$cats_ids[] = $tb_related_cat->term_id;
}
// Query args
$args = array(
'posts_per_page' => tb_get_mod( 'blog_related_count', '3' ),
'orderby' => 'rand',
'category__in' => $cats_ids,
'post__not_in' => array( get_the_ID() ),
'no_found_rows' => true,
'tax_query' => array (
'relation' => 'AND',
array (
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-quote', 'post-format-link' ),
'operator' => 'NOT IN',
),
),
);
$args = apply_filters( 'tb_blog_post_related_query_args', $args );
// Related query arguments
$tb_related_query = new wp_query( $args );
// If the custom query returns post display related posts section
if ( $tb_related_query->have_posts() ) :
// Wrapper classes
$classes = 'related-posts clr';
if ( 'full-screen' == tb_global_obj( 'post_layout' ) ) {
$classes .= ' container';
} ?>
<div class="<?php echo $classes; ?>">
<?php get_template_part( 'partials/blog/blog-single-related', 'heading' ); ?>
<div class="tb-row clr">
<?php $tb_count = 0; ?>
<?php foreach( $tb_related_query->posts as $post ) : setup_postdata( $post ); ?>
<?php $tb_count++; ?>
<?php include( locate_template( 'partials/blog/blog-single-related-entry.php' ) ); ?>
<?php if ( $tb_columns == $tb_count ) $tb_count=0; ?>
<?php endforeach; ?>
</div><!-- .tb-row -->
</div><!-- .related-posts -->
<?php endif; ?>
<?php wp_reset_postdata(); ?>