Replies: 0
Hi keesiemeijer greetings 4m India, this is in regard to this topic https://wordpress.org/support/topic/countdisplay-common-and-total-terms-bw-two-posts/ that i asked u earlier and u helped me acheving the desired result.
Earlier i used this shortcode
[related_posts_by_tax taxonomies="hindi-chords" post_types="hindi-songs" posts_per_page="5" title="More Songs On Similar Chords"]
And used this code that u provided me, in sitespecific plugin
add_filter( 'related_posts_by_taxonomy', 'rpbt_add_common_terms', 10, 4 );
function rpbt_add_common_terms( $related, $post_id, $taxonomies, $args ) {
if ( !( isset( $args['related_terms'] ) && $args['related_terms'] ) ) {
return $related;
}
// get the terms (objects) used to calculate the related posts
$related_terms = get_terms( array(
'taxonomy' => $taxonomies,
'include' => $args['related_terms'],
) );
// get the term names
$names = wp_list_pluck( $related_terms, 'name', 'term_id' );
foreach ( $related as $key => $post ) {
// Get the terms from the related post.
$terms = wp_get_object_terms( $post->ID, $taxonomies, array( 'fields' => 'ids' ) );
// Get common terms from the related post as array keys.
$in_common = array_flip( array_intersect( $terms, $args['related_terms'] ) );
// Get the term names.
$in_common = array_intersect_key( $names, $in_common );
$title = count( $in_common ) . '/' . count( $terms );
$title .= ' Chords Common – ' . implode( ', ', $in_common );
$related[$key]->in_common = $title;
}
return $related;
}
But now i changed the shortcode to this below for thumbnails
[related_posts_by_tax format="images" image_size="medium" taxonomies="hindi-chords" post_types="hindi-songs" posts_per_page="5" title="More Songs On Similar Chords"]
now common terms are not showing totally at all as it was showin earlier.
Thanks in advance 🙂