Oct 7, 2011

The content limit function for wordpress


function the_content_limit($max_char, $more_link_text = '(more...)'
$stripteaser = 0, $more_file = '') {
$content = get_the_content($more_link_text, 
$stripteaser, $more_file);
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
$content = strip_tags($content);

if (strlen($_GET['p']) > 0) {
echo "";
echo $content;
echo "<a href=""the_permalink();</p> <p> 
     echo "">"."Read More</a>";
echo "";
}

elseif ((strlen($content)>$max_char) &&
 ($espacio = strpos($content, " ", $max_char ))) {
$content = substr($content, 0, $espacio);
$content = $content;
echo "
";
echo $content;
echo "...";
echo <a href="";echo the_permalink(); 
echo "">".$more_link_text."</a>";
echo "
";
}

else {
echo "
";
echo $content;
echo "<a href="";echo the_permalink();echo "">"."Read More</a>";
echo "";
}
}

4 comments:

Kerala Hotels said...

Thanks for the info..it helps for my kerala hotel website

Unknown said...

Thanks so much for this helpful information come back again for more interesting information…Keep it up
Wordpress Developers

Deepa said...

I am not able to locate this function in the function.php file
Is this a custom function? If so, where do i place this and how do i execute this?

Unknown said...

My on the internet and I came over here by a different website and regarded I should assess elements out. I like what I see so now I’m following you.

Wordpress Development Bangalore | Joomla Developers Bangalore

Post a Comment