How to Truncate WordPress Post Titles with PHP


How to Truncate WordPress Post Titles with PHP
Sherita Diamond

Make sure you edit the $thelength variable from 25 to the character count of your need. You would have to estimate the count for your theme design. The code adds the length variable and then use the conditional tag to see if the title length matches our desired length. If it is longer, then the code adds ‘…’ in front. Most of the time, you will use this only on specific areas where the width is fixed in the theme.

Be the first to comment

Leave a Reply

Your email address will not be published.


*