Posted By

kristapslazda on 08/30/10


Tagged

wordpress title truncate


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

athanassiadis


Truncate wordpress title


 / Published in: PHP
 

URL: http://codezroz.com/php/truncate-wordpress-titles-with-php/

Paste the following code to replace your the_title tag in the loop. Make sure you edit the $thelength variable from 25 to the character count of your need.

  1. <a href="<?php the_permalink() ?>">
  2. <?php
  3. $thetitle = $post->post_title; /* or you can use get_the_title() */
  4. $getlength = strlen($thetitle);
  5. $thelength = 25;
  6. echo substr($thetitle, 0, $thelength);
  7. if ($getlength > $thelength) echo "...";
  8. ?>
  9. </a>

Report this snippet  

You need to login to post a comment.