Truncate WordPress post content

$post_content = $post->post_content; // get the content
$post_content = strip_tags($post_content); // remove HTML tags
$post_content = preg_replace('/\[(.*)\]/', '', $post_content);  // remove shortcodes
$post_content = substr($post_content, 0, 30);
echo $post_content;

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

IMPORTANT! To be able to proceed, you need to solve the following simple math (so I know that you are a human) :-)

What is 6 + 2 ?
Please leave these two fields as-is: