' . wp_filter_post_kses( stripslashes( $text ) ) . '
';
}
}
endif;
if ( ! function_exists( 'biancaa_related_posts' ) ) :
/**
* Related posts.
*
* @since 1.0.0
*/
function biancaa_related_posts() {
// Only display related posts on single post.
if ( ! is_single() ) {
return;
}
// Get the taxonomy terms of the current page for the specified taxonomy.
$terms = wp_get_post_terms( get_the_ID(), 'category', array( 'fields' => 'ids' ) );
// Bail if term empty.
if ( empty( $terms ) ) {
return;
}
// Query arguments.
$query = array(
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => $terms,
'operator' => 'IN'
)
),
'posts_per_page' => 3,
'exclude' => get_the_ID(),
'post_type' => 'post',
);
// Allow plugins/themes developer to filter the default query.
$query = apply_filters( 'biancaa_related_posts_query', $query );
// Perform the query.
$related = new WP_Query( $query );
if ( $related->have_posts() ) :
$html = '