I wrote some code in my functions.php to make a blog title smaller when too long, but i would also like to target another css class called .slide-entry in my blog page. So in the first if statement, i would like to also change the line-height of the slide-entry class. this is my code:

if (strlen($title) > 34 && $title < 51) {
    $title = '<span style="font-size: 15px">' . $title . '</span>';
    //target css class and change line height
if (strlen($title) > 50) {
    $title = '<span style="font-size: 10px">' . $title . '</span>';

Anybody know a good way to do this?

  • 4
    Wouldn't it be easier to set a HTML class, e.g. class="long-title" etc instead of putting an inline style? Then you could add your CSS in a CSS file and use normal CSS rules to target .slide-entry – Tom J Nowell Feb 17 at 15:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.