Skip to content

Instantly share code, notes, and snippets.

@bugsysop
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bugsysop/54a31fd4fabf22d07a3c to your computer and use it in GitHub Desktop.
Save bugsysop/54a31fd4fabf22d07a3c to your computer and use it in GitHub Desktop.
Kirby - Extract the first paragraph from an article
<?php
//If you want to remove the paragraph tags from the resulting string, uncomment the second line of the function.
function getFirstPara($string){
$string = substr($string,0, strpos($string, "</p>")+4);
//$string = str_replace("<p>", "", str_replace("<p/>", "", $string));
return $string;
}
$text = getFirstPara(kirbytext($page->text())); ?>
?>
<?php echo $text?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment