• Resolved thisisedie

    (@thisisedie)


    I could swear I found the answer here a long time ago but I can’t find it now and I need it. I want to trim the beginning X number of characters from a title. What I had before was just a simple little tag calling the title and I put the number of characters I wanted to skip in it. Any help would be appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • What did you have before? And why do you not have it now?

    This should do it though:

    function my_truncate_title($title) {
      return substr($title,5);
    }
    add_filter('the_title','my_truncate_title');

    Put it in your theme’s functions.php. Change the number to whatever you want to skip.

    Thread Starter thisisedie

    (@thisisedie)

    Well obviously I didn’t know what I had before or I wouldn’t have needed it and I didn’t have it because I changed things up and lost it.

    Thank you much for your help but that’s not what I was looking for. I didn’t wanna change all titles just the titles on a particular loop. This is the solution for anyone who’s interested. The 11 is how many characters you’d like to shave off the beginning of the title and the 100 is the max number of characters the title can be. There’s probably a better way to do it but this works perfectly :o)

    <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php echo substr(the_title('','',false),11,100); ?></a>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Truncate Beginning Of Title’ is closed to new replies.