WordPress
<?php the_content();?>
I would like to add a class to the p,h2,h3 output in .
<p class="my-class-name">Aiueo</p>
I want to do something like that.
I found that I would add a different class to the body element, but I don't know how to add it to the body.Please let me know.
body_class()|Function|WordPress Developer Resources
wordpress
Instead of the_content(); you should use get_the_content(); to retrieve the contents of the body and edit them to the desired design.
Here is a simple example using str_replace
$content_string=get_the_content();
$content_string = str_replace('<p','<p class="classname"', $content_string);
$content_string = str_replace('<h2', '<h2class="classname"', $content_string);
$content_string = str_replace('<h3', '<h3class="classname"', $content_string);
echo$content_string;
582 PHP ssh2_scp_send fails to send files as intended
613 GDB gets version error when attempting to debug with the Presense SDK (IDE)
620 Uncaught (inpromise) Error on Electron: An object could not be cloned
916 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.