Skip to content

Instantly share code, notes, and snippets.

@CNG
Created November 3, 2011 19:44
Show Gist options
  • Save CNG/1337577 to your computer and use it in GitHub Desktop.
Save CNG/1337577 to your computer and use it in GitHub Desktop.
Movable Type two paragraph excerpt with php
<?php
$body = <<<EOT
<$mt:EntryBody encode_php="here"$>
EOT;
preg_match_all('#<p>(.+?)</p>#is', $body, $matches);
switch(count($matches[0])) {
case 0: break;
case 1: echo $matches[0][0]; break;
case 2: echo $matches[0][0].$matches[0][1]; break;
default: echo $matches[0][0]."<p>".$matches[1][1].' <a href="<mt:EntryPermalink>" class="actionlink">Read more &raquo;</a>'; break;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment