Getting the first paragraph of post on WordPress

Getting the first paragraph is a handy function for WordPress because we can use this on almost every page of a website.
You can use this function to get the first paragraph:


function get_first_paragraph(){
	global $post;
	
	$str = wpautop( get_the_content() );
	$str = substr( $str, 0, strpos( $str, '</p>' ) + 4 );
	$str = strip_tags($str, '<a><strong><em>');
	return '<p>' . $str . '</p>';
}