Filter post style attribute

Looking for a hook which enables filtering of a class within the post or content so i can add inline CSS using custom fields for posts on the home page.

Something like this -

add_filter( 'attr_entry', 'filter_post_html_tag' );
function filter_post_html_tag( $attributes ) {

    $color = get_post_meta( get_the_ID(), 'background_color', true );
            
    $colors = $color ? $color : 'grey';

    $attributes['style']  = 'color:' . $colors . '';

    return $attributes;
}

Topic the-content css custom-field Wordpress

Category Web


What you are looking for is post_class filter.
However, it depends on the theme you are using and how they used the loop

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.