Hi,
Today, i we will show you post content limit in wordpress. This article will give you simple example of post content limit in wordpress. you will learn post content limit in wordpress. So let’s follow few step to create example of post content limit in wordpress.
Copy the code and add it to your functions.php file :
///////////////content limit 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,'<p>'); if (strlen($_GET['p']) > 0) { echo $content; echo " <a rel='nofollow' href='"; the_permalink(); echo "'>".__('Read More', 'studiopress')." →</a>"; } else if ((strlen($content)>$max_char) && ($espacio = strpos($content, " ", $max_char ))) { $content = substr($content, 0, $espacio); $content = $content; echo $content; echo "..."; } else { echo $content; } }
You can get content by doing this function in your file:
<?php the_content_limit(60); ?>