Forums

Inject small tag in Post TITLE to reduce it (2 posts)

  1. binbin
    Member
    Posted 2 years ago #

    Hello,

    I want to reduce the size of some of titles post when they are too long to fit in my post design.

    To do this in my opinion one of the best way will be to inject when it only necessary a <small></small> or <FONT SIZE="-1"> in my Title code.

    So,do you know a Plug ins that can give me the possibility to do this or a solution to put this feature in my template theme files using custom fields... ?

    thanks

  2. esmi
    Theme Diva & Forum Moderator
    Posted 2 years ago #

    You can't insert markup into the title itself. What you might be able to do is amend the template file so that it counts the number of characters in the post title and, once they exceed a given number, apply a class that then be styled via the theme's stylesheet. So:

    <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    would be changed to something like:

    <h2<?php if( strlen(the_title('','',false)) > 50 ) echo ' class="small"';?>><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

    Then, in the theme's stylesheet:

    h2.small {font-size:.7em;}

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags