Last active
August 29, 2015 14:05
-
-
Save bugsysop/54a31fd4fabf22d07a3c to your computer and use it in GitHub Desktop.
Kirby - Extract the first paragraph from an article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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