-
-
Save kerihenare/9557715 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
/** | |
* | |
* @param string $moreLinkText | |
* @param integer $stripteaser | |
*/ | |
function the_content_readmore($moreLinkText = null, $stripteaser = 0) | |
{ | |
$content = apply_filters('the_content', get_the_content($moreLinkText, $stripteaser)); | |
$paragraphs = explode('</p>', $content); | |
// If there's only one paragraph, echo the content and return | |
if (2 === count($paragraphs)) { | |
echo $content; | |
return; | |
} | |
// Always echo first paragraph | |
echo $paragraphs[0] . '</p>'; | |
// If the first paragraph has an iframe, also echo second paragraph | |
if (false !== stripos($paragraphs[0], '<iframe')) { | |
echo $paragraphs[1] . '</p>'; | |
} | |
echo '<a href="javascript:void(0);" class="button button-more">Read More <i class="fa fa-lg fa-chevron-circle-down"></i></a>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment