Limit WordPress Post or Page Content

Copy this function and paste in the function.php
function dp_clean($excerpt, $substr=0) {
$string = strip_tags(str_replace(‘[…]‘, ‘…’, $excerpt));
if ($substr>0) {
$string = substr($string, 0, $substr);
return $string;

Call this function in your index.php

< ?php echo dp_clean($post->post_content, 250); ? >

Muhammad Faridul Islam
Muhammad Faridul Islam is an entrepreneur, web developer, and IT Consultant. Besides his profession, he also writes a blog here.

One Response to Limit WordPress Post or Page Content

  1. zenna says:

    Thanks for ur post.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.