Support » Themes and Templates » Limit for title length

  • I am looking for a way/code to limit the title length in the recent comments section of my website (

    For example, with very long titles such as ”2010 LAMBORGHINI GALLARDO LP550-2 VB”

    I do not want it to say User @ ”2010 LAMBORGHINI GALLARDO LP550-2 VB” because that is too long and it creates two lines for one entry and with a total of 4 entries it moves the copyright under it everytime and it could get annoying for users.

    I would just want to be able to set a limit for it at a maximum of certain amount of words or characters, can this be done ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • Try editing style.css and changing:

    #footer #footerbar #footerbar-center {
    padding:0 14px 0 11px;


    #footer #footerbar #footerbar-center {
    padding:0 14px 0 11px;

    Then add:

    #footer #footerbar #footerbar-center li a {white-space:nowrap;}

    to the bottom of style.css.

    Hey esmi, thank you for the reply. I tried out what you said and it’s almost what I want. I should’ve explained just a bit better. Before it would do the following;

    User @ ”2010 LAMBORGHINI GALLARDO LP550-2 VB”

    With what you suggested, it just cuts out as soon as it reaches the line which does avoid the fact that it double lines.

    Here is what I want it to do;

    User @ ”2010 LAMBORGHINI GALLAR…”

    Like it would input the three dots after a certain amount of characters and then would close with the ”, is this possible ?

    Thanks again!

    Not possible with CSS I’m afraid (which was the easy, quick, fix). You’d need to delve into the code to create the effect you want. Are you using the Recent Comments widget from Admin/Appearance/Widgets? Or does the theme create the Recent Comments itself?

    Here’s how to do it:

    $tit = the_title('','',FALSE);
    echo substr($tit, 0, 55);
    if (strlen($tit) > 55) echo " ...";

    You’d have to edit the comments section a little, but you can definately set how long the comment title will be with this.

    @ esmi; the theme creates it.

    @jb; thank you for the code but I have two questions. For one, will the code you gave me apply to comments that people will make in my articles ? For two, exactly where do I put this in the comments php ? :/

    Just in case, here’s the code that creates the recent comments;

    <div id="footerbar-center">
    				<h3>Recent Comments</h3>
    				<ul class="footerbar-center-in">
    <?php						$sql = "SELECT * FROM $wpdb->comments LEFT OUTER JOIN $wpdb->posts ON ($wpdb->comments.comment_post_ID = $wpdb->posts.ID) WHERE comment_approved = '1' AND comment_type = '' ORDER BY comment_date DESC LIMIT 0 , 4";						$comments = $wpdb->get_results($sql);						foreach ($comments as $comment) {							$data = $comment->comment_author . " @ [" . $comment->post_title;							echo "
    <li><a>comment_post_ID) . "\">" . substr($data,0,40) . "]</a></li>
    ";   						}					?> 

    bump for some clarification… :/

    foreach ($comments as $comment) {
      $title = $comment->comment_author . " @ [" . $comment->post_title;
      echo "<a href=\'your link here\'>";
      echo substr($title, 0, 40);
      echo "</a>]";

    That should work – have you tried it?

    Im sorry, I was away for a couple of days and wasnt able to do it in that time but yes indeed I just tried it today and its not working out too well :/

    For one it isn’t giving the appropriate link to each article, it’s just giving an ending as follows; \’your

    It also isn’t ordered with bullets anymore, along with the font being different too, everything is underlined now too and there is no […] when the title exceeds the number of characters.

    Here’s a picture of it now with the change you suggested;

    & here’s a picture of it before;

    Any ideas on how to fix or there’s no real way to do this ?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Limit for title length’ is closed to new replies.