Created
March 14, 2014 21:36
-
-
Save mattbrett/9557507 to your computer and use it in GitHub Desktop.
Works, but always adds more button, even if there's only one paragraph.
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 | |
function the_content_readmore($more_link_text = null, $stripteaser = 0) { | |
$content = get_the_content($more_link_text, $stripteaser); | |
$content = apply_filters('the_content', $content); | |
$content = explode("</p>", $content); | |
foreach ($content as $key => $value){ | |
if ($value != null || $value != ''){ | |
if ( !stripos( $content[$key], '<iframe' ) === false ){ | |
echo $content[$key]; | |
for($i = $key+1; $i < count($content); $i++ ){ | |
echo $content[$i]; | |
if ($content[$i] != null || $content[$i] != '') break; | |
} | |
} | |
else{ | |
for($i = $key; $i < count($content); $i++ ){ | |
echo $content[$i]; | |
if ($content[$i] != null || $content[$i] != '') break; | |
} | |
} | |
break; | |
} | |
else echo $value; | |
} | |
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
Total rewrite but this should do what you want: https://gist.github.com/kerihenare/9557715