How to add an inline style to the tag outputted in the_content() using PHP?

Thanks to @papirtiger

Came up with this solution just to apply it to a specific content function.

I did not explain in my question that I only needed to work on a specific the_content, instead I think the above solutions are a global solutions, and both are great solutions from that point of view.

<?php 

    $phrase = get_the_content();
    // This is where wordpress filters the content text and adds paragraphs
    $phrase = apply_filters('the_content', $phrase);
    $replace="<p style="text-align: left; font-family: Georgia, Times, serif; font-size: 14px; line-height: 22px; color: #1b3d52; font-weight: normal; margin: 15px 0px; font-style: italic;">";

    echo str_replace('<p>', $replace, $phrase);

?>

Leave a Comment