• Home
  • About Me
  • Disclaimer
  • Privacy Policy
  • Portfolio Site
  • WordPress Development Service
  • WP Hosting

Banna360

WordPress Codes | Mobile App Reviews | Web, Android, iOS, Technology and More

Web, Android, iOS, Technology and More…

Mobile App Reviews | WordPress Codes

  • Home
  • Blog
  • iOS App Reviews
  • WordPress
  • Web Design
  • Web Development
  • PHP
  • General
  • Contact
You are here: Home / Web Development / How to Reduce the Character Length of WordPress Post Title

How to Reduce the Character Length of WordPress Post Title

WordPress by default display fill title if you code it using via the_title() function. You can reduced the number of character display by using following simple code.

<h1><a href="<?php echo get_permalink() ?>"> 
<?php  
$title_temp=the_title('','',false); 
if(strlen($title_temp) > 30) { 
$title_temp = substr($title_temp, 0, 30) . '...'; 
}  
echo $title_temp; 
?></a></h1>

For example if you have space for 50 character in titles area of wordpress in your design. You can use this code to reduce the wordpress title display. The main attractive of this method is you can use only areas you needed.

How to use WordPress reduced titles in different areas of theme?

If you want do it on more programatic way or want use same type of titles in some other areas of the theme. I recommend using following method. First add this code to your function.php file in your theme.

function the_title_excerpt($before = '', $after = '', $echo = true, $length = false) 
  {
    $title = get_the_title();

    if ( $length && is_numeric($length) ) {
        $title = substr( $title, 0, $length );
    }

    if ( strlen($title)> 0 ) {
        $title = apply_filters('the_title_excerpt', $before . $title . $after, $before, $after);
        if ( $echo )
            echo $title;
        else
            return $title;
    }
}

Then call it like this in your theme where you want display the title.

<?php the_title_excerpt('', '...', true, '50'); ?>

 

Filed Under: Web Development, Wordpress

Facebook Fans

Banna360

Recents Updates

Top backup plugins for WordPress

Contact Form 7 Boilerplate for Bootstrap CSS theme

GST For Freelancers and Service Sector

Display Related Post or Product based on Taxonomy in WordPress

Categories

  • Android App
  • Featured Post
  • General
  • iOS App Reviews
  • PHP
  • Web Design
  • Web Development
  • Wordpress

Android Apps

Friendly App review – The best alternative app for Facebook lite and messenger

If you are a person who likes to keep your personal life away from the work, Then Friendly App is for you. Multiple Facebook accounts on a single app, sounds great right? This app has a lot more to offer to make your Facebook experience even better. The Friendly For Facebook app is built by getting […]

My Jio App Review – The best way to track down your Jio Data usage

My Jio is an exclusive app from Reliance Jio digital service for its jio users where one can do tasks like keeping track on their usage to managing and recharging their Jio account. My Jio app had gone through many updates after its release, in the latest update for android the version 3.2.42 has nothing […]

About Me

Banna a professional Web developer with a specialization in WordPress web design, having worked on more than 200 individual WordPress projects and sites over the course of my career.As a specialist in WordPress development, I can help with all aspects of taking your WordPress project from start to finish.

READ MORE ABOUT ME

Recent Posts

  • UpdraftPlus – A Complete Study
  • Top backup plugins for WordPress
  • Contact Form 7 Boilerplate for Bootstrap CSS theme
  • GST For Freelancers and Service Sector
  • Display Related Post or Product based on Taxonomy in WordPress

Tags

autoupdate wordpress best translator app bhim app contact form 7 Friendly App review Gst freelancers LinkedIn redesign metabox my jio app MYSQL Productivity tips shortcode api upi app for ios whatsapp bug whatsapp uae why telegram wordpress.org wordpress hosting wordpress plugins wordpress tutorial zip using php

Copyright © 2025 · Magazine Pro Theme on Genesis Framework · WordPress · Log in