I have a piece of code that extracts the first paragraph from the post, enclosed in a p
tag.
I want to add a "Read more" link inside the p
tag referring to "the full post".
Please help.
function first_paragraph() {
global $post, $posts;
$first_para = '';
ob_start();
ob_end_clean();
$post_content = $post->post_content;
$post_content = apply_filters('the_content', $post_content);
$output = preg_match_all('%(<p[^>]*>.*?</p>)%i', $post_content, $matches);
$first_para = $matches [1] [0];
echo $first_para;
}