moviezzworld
Active Member
Hello friends anyone tell how can i short post title in home page,
Thanks,
Thanks,
function ShortenText($text) { $chars_limit = 100; $chars_text = strlen($text); $text = $text." "; $text = substr($text,0,$chars_limit); $text = substr($text,0,strrpos($text,' '));
if ($chars_text > $chars_limit) { $text = $text."..."; } return $text;}
$chars_limit
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<h1><?php echo ShortenText(get_the_title()); ?></h1>
<div class="post-title"><?php the_content(); ?></div>
<?php endwhile; endif; ?>