This snippet will allow you to define a custom truncate length of the WordPress post title in your template files.

Add this to your functions.php file.

   function cptl_title($char) {
      $title = get_the_title($post->ID);
      $title = substr($title,0,$char);
      echo $title;

And then add this to your template file where you want the post title to be displayed.

<?php cptl_title(100); ?>

*note – the number 100 is the characters allowed before title is being truncated. You can define any differently character amount on each post title thru-out your templates.


Leave a Reply

Your email address will not be published. Required fields are marked *

Contact Us

This could be the beginning of something great 🙌

"*" indicates required fields


By submitting this form: You agree to the processing of the submitted data in accordance with WP Dynamics Privacy Policy.

Contact Information
You can also write us an email or contact us by telephone.
Telephone +45 71 74 71 21

Support For support inquiries, please refer to our support section.

Recent Articles

Faust.js – A Headless Framework for WordPress

Faust.js is a Headless WordPress Framework that provides a set of tools for building front-end applications based on WordPress ...

How to Load (Enqueue) and Handle Assets and Dependencies in WordPress

In WordPress, instead of adding assets such as styles and JavaScript to the header, you can and should use ...

An Introduction to Google Tag Manager Server-side Tagging

WordPress has come a long way since its launch in 2003 - from a blogging tool to a full-fledge ...