I made a custom p class for text in my Wordpress site. The trouble is, the CSS is coded in such way, if I put the properties from that p class on the default p - it messes up the layout.
So to get the text layout I want, I need to put in front of every paragraph - and that's very annoying.
Is there a way to make that custom p class the default p by wordpress?
You have to insert this into your functions.php file in order to replace all your <p>
with something like <p class="class">
.
function paragraph_replace($content){
return preg_replace('/<p([^>]+)?>/', '<p$1 class="class">', $content);
}
add_filter('the_content', 'paragraph_replace');
Then you can easily address this class through CSS.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.