/ Published in: PHP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$content = $post->content; if(preg_match_all('#<p>(.*)</p>#simU', $content, $m1, PREG_SET_ORDER) && count($m1) >= 2) { // more than 2 paragraphs $trim = $site_settings->blog->preview->trim_length; if($l_1 < ($trim * 0.75) && $l_2 < $trim) { $content = '<p>' . $m1[0][1] . '</p>' . '<p>' . $m1[1][1] . '</p>';//substr($content, 0, $l_1 + $l_2 + 7 + 7 + 2); } else if($l_1 < $trim) { $content = '<p>' . $m1[0][1] . '</p>'; //substr($content, 0, $l_1 + 7); } else { } }