• Resolved bmg

    (@bridgetg)


    Hey

    Everything is working perfectly, however, the thumbnail links to the related post but the actual title of the post is not an active link. How do I add the url to the title of the post?

    I’m assuming it’s in functions-thumbnail.php

    I see the thumbnail has this code

    $output .=  "<a href='$url' title='$post_title'>$gallery_image</a>\n";
    			}

    not sure how to format this for the title and what I should replace.

    Thanks!

    https://www.ads-software.com/plugins/related-posts-by-taxonomy/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    Hi bmg

    Can you explain more about what you mean by “but the actual title of the post is not an active link.” Does it mean the post doesn’t have a title, or something else?

    The file is correct but the code you posted is for related post thumbnails in a feed. Maybe you meant this:

    $image_output =  "<a href='$url' title='$post_title_attr'>$gallery_image</a>";

    Thread Starter bmg

    (@bridgetg)

    Sorry, I meant that the title isn’t an active link to the post, it just shows up as text. So in order to view the post, I have to click the thumbnail. I would like to be able to click both the thumbnail and the title of the story to link me to the post page.

    Plugin Author keesiemeijer

    (@keesiemeijer)

    No problem ??

    Try it with this in your theme’s functions.php

    add_filter( 'related_posts_by_taxonomy_caption', 'link_related_caption', 10, 3 );
    function link_related_caption( $caption, $related, $args ) {
        $caption = '<a href=' . get_permalink( $related->ID ) . '>' . $caption . '</a>';
        return $caption;
    }

    If you need it with the post date (as in the other topic) use this:

    add_filter( 'related_posts_by_taxonomy_caption', 'link_related_caption', 10, 3 );
    function link_related_caption( $caption, $related, $args ) {
    	$date = '<span class="related-post-date">';
    	$date .= get_the_date( get_option( 'date_format' ), $related->ID );
    	$date .= '</span>';
    
    	$caption = '<a href=' . get_permalink( $related->ID ) . '>' . $date . $caption . '</a>';
    	return $caption;
    }

    https://keesiemeijer.wordpress.com/related-posts-by-taxonomy/filters/#related_posts_by_taxonomy_caption

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Title hyperlink with Thumbnail Template’ is closed to new replies.