Skip to content

Instantly share code, notes, and snippets.

@alnutile
Last active December 21, 2015 16:59
Show Gist options
  • Save alnutile/6337116 to your computer and use it in GitHub Desktop.
Save alnutile/6337116 to your computer and use it in GitHub Desktop.
/**
* File Path
* themes/incrediblewp/template-portfolio4col-content.php
* This is the alter pages that are Wordpress Pages that then have under it the
* Template 4 column like the parking url.
*/
// Line 123
<?php
$excerpt = get_the_excerpt();
$permalink = get_permalink();
$short_excerpt = string_limit_words($excerpt, 50, $permalink);
if(ot_get_option('incr_portfolio_text')== 'excerpt') {
echo '<p>'.$excerpt.'</p>';
} else {
echo '<p>'.$short_excerpt.'</p>';
}
?>
<?php
//Path
//themes/incrediblewp/backend/helpers.php
function string_limit_words($string, $word_limit, $link) {
$words = explode(' ', $string, ($word_limit + 1));
if (count($words) > $word_limit) {
array_pop($words);
//I added the Read More option
return implode(' ', $words) . "... <a href=\"$link\">Read More..</a>";
} else {
//otherwise
return implode(' ', $words);
}
}
?>
<?php
//Path
//themes/incrediblewp/helpers.php
$excerpt = get_the_excerpt();
$permalink = get_permalink();
$short_excerpt = string_limit_words($excerpt,50, $permalink);
if(ot_get_option('incr_portfolio_text')== 'excerpt') {
echo '<p>'.$excerpt.'</p>';
} else {
echo '<p>'.$short_excerpt.'</p>';
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment