filters – How to run php code only for a specific widget on a page and not all widgets on that page?

I want to display extra information below the post title only for the posts block on the home page and not the portfolio. I’m using WordPress’ the_title filter to do this and that works fine, but at the moment, it shows the extra info in both the portfolio and the posts block. I need a condition to restrict the filtering only to the posts block. The post block’s class name is “home-post-block”

My current code looks like this.

function add_rating_html( $title) {

    if (in_the_loop()){
        $out = "Rating: 5";
        $title .= $out;
    }
    return $title;
}

add_filter('the_title', 'add_rating_html',1);

Any help would be most appreciated.