Support » Themes and Templates » CSS title too long

  • I don’t know what its called but if my title was too long how would keep it within 1 column without it going into another column like for example
    “how are you today good
    or sad?”
    but i want this
    “how are you today go…”

Viewing 11 replies - 1 through 11 (of 11 total)
  • anyone?

    Here’s one way you could do it:

    In your template file where you want to implement this (single.php for post pages, index.php for the homepage, etc), find


    Every time you find the_title(), replace it with this:

    if(strlen($post->post_title)>5){echo substr($post->post_title,0,5).'...';}else{the_title();}

    Just replace the 5s with however many letters you want in your titles.

    thanks alot, I’m trying to add it for the visual recent post plugin for the titles but it just doesn’t seem to work for me…



    Forum Moderator

    Alternative suggestion:
    Locate the_title as before but just note what markup is being used around it. Might be something like:

    <h2 class="post-title"><a href="<?php the_permalink();?>" title="<?php the_title();?> - permanent link"><?php the_title();?></a></h2>

    In this example, an H2with the class post-title is the info you want.

    Next open the style.css file. At the very bottom of this file, add: {width:90%;)

    That should force longer titles to wordwrap over 2 lines or more and stop then overlapping another column. Saves you cutting some titles off mid-word.

    If you’re having problems with the precise CSS that you need to add, post your blog url and I’ll see if I can come up with a less general solution.

    yea but this is a plugin it has its on css and the coding of it so long everytime i try to change it it gives me a error…



    Forum Moderator

    Does the plugin have it’s own CSS file? If so, you could edit that. If not, then it really depends upon where the CSS is added and how. That in turn determines if/how the post title style can rewritten. A link to your site might help.

    if($vrpOptions['post_title_after_image'] == 'false') {
    					  if($vrpOptions['include_post_title'] == 'true') {
    						  echo '<div id="vrp_title_caption" style="';
    						  if($vrpOptions['post_title_ptop'] != '') echo 'padding-top:'.$vrpOptions['post_title_ptop'].'px;';
    						  if($vrpOptions['post_title_pright'] != '') echo 'padding-right:'.$vrpOptions['post_title_pright'].'px;';
    						  if($vrpOptions['post_title_pbottom'] != '') echo 'padding-bottom:'.$vrpOptions['post_title_pbottom'].'px;';
    						  if($vrpOptions['post_title_pleft'] != '') echo 'padding-left:'.$vrpOptions['post_title_pleft'].'px;';
    						  echo '"><h3><a style=" font-size:'.$vrpOptions['title_caption_font_size'].'px;';
    						  echo '" href="';
    						  echo the_permalink();
    						  echo '">';
    						  echo the_category(' ');
    						  echo '</a></h3></div>';
    					  } else {
    						  //echo '<div></div>';

    thats the code I’m trying to edit, I’m trying to get it to how peter showed me since I only waant 17 characters followed by ‘…’ but I have no idea how to add it in that way. also tried the css method didn’t go the way i wanted.

    I installed the plugin to figure out how to get this – and the code is all over the place. I didn’t take the time to figure out what exactly was going on, but for some reason the_title() is called a lot of times, in a lot of different places (it looks like it does this to handle the various display options you have).

    You need to either: Find which code block applies to the display option you’re using, and find every instance of the_title() in that block,replacing it with:

    if(strlen($post->post_title)>17){echo substr($post->post_title,0,17).'...';}else{the_title();}

    or just find every instance of the_title() in the visual-recent-posts.php file and replace them with that.

    It definitely works, you just need to make sure tht you get the right instance of the_title().

    I know it works but i have to place it in separate echo functions and i only have to place it in the_title once because the the_title for the other ones are for other functions that i don’t use. the only thing is I’m not use to using echo…

    well i tried to replace it, i get a syntax error maybe its too long for a echo function.. well I’m using the_category(” “) i don’t have to change much, right if i finally get it?

    peter your code worked but how do i change it to category names that link to the category?

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘CSS title too long’ is closed to new replies.