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 widget on the home page and not the portfolio widget. 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 widgets. I need a condition to restrict the filtering only to the posts widget. The post widget's class name is home-post-widget
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.
Topic widget-text php filters Wordpress
Category Web