Support » Plugin: Related Posts by Taxonomy » Display only Title and Category using shortcode

  • Hi, thank you for making this plugin and for making it available.

    I have a small problem that I hope you could assist with. I am showing posts related by tag. I would like to display the Thumbnail + title + post category. Using shortcodes, I have only managed to show the title alone or the entire metadata using this shortcode.

    [related_posts_by_tax taxonomies=”post_tag” format=”thumbnails” image_size=”medium” posts_per_page=”10″ caption=”post_excerpt” link_caption=”true” title=”באותם נושאים”]

    Any help would be appreciated.

    Thanks much,

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author keesiemeijer


    Hi zschneider

    Sorry for the late reply. Try adding the category with this in your (child) theme’s functions.php

    add_filter( 'related_posts_by_taxonomy_caption', 'rpbt_add_category_to_gallery_caption', 10, 2 );
    function rpbt_add_category_to_gallery_caption( $caption, $post ) {
    	$terms = get_the_terms( $post, 'category' );
    	if ( is_wp_error( $terms ) || ! isset( $terms[0] ) ) {
    		return $caption;
    	$term = $terms[0];
    	$cat_link .= '<a href="' . esc_url( get_term_link( $term->term_id, 'category' ) ) . '">' . $term->name . '</a>';
    	return  $caption . ' - ' . $cat_link;

    It will add the link to the post category after the caption

    consider creating a child theme instead of editing your theme directly – if you upgrade the theme all your modifications will be lost. Or create a plugin with the code above.

    • This reply was modified 1 year, 8 months ago by  keesiemeijer.
Viewing 1 replies (of 1 total)
  • The topic ‘Display only Title and Category using shortcode’ is closed to new replies.