nightware |
Mar 26, 2010 10:47 PM |
Bug: Excerpts in Atahualpa
Hi Guys, I just discovered a bug, that was teasing me in the Atahualpa 3.4.6 Theme.
When using excerpts on a Archive or Category page, the last Word of the excerpt is dropped.
This is due to an error in the functions.php.
Instead of
PHP Code:
// Custom Excerpts
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed
global $bfa_ata;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text, $bfa_ata['dont_strip_excerpts']);
$excerpt_length = $bfa_ata['excerpt_length'];
$words = explode(' ', $text, $excerpt_length + 1);
} else {
$words = explode(' ', $text);
}
if (count($words) > $excerpt_length) {
array_pop($words);
$custom_read_more = str_replace('%permalink%', get_permalink(), $bfa_ata['custom_read_more']);
$custom_read_more = str_replace('%title%', the_title('','',FALSE), $custom_read_more);
array_push($words, $custom_read_more);
$text = implode(' ', $words);
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'bfa_wp_trim_excerpt');
it should be
PHP Code:
// Custom Excerpts
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed
global $bfa_ata;
$excerpt_length = $bfa_ata['excerpt_length'];
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = strip_tags($text, $bfa_ata['dont_strip_excerpts']);
$words = explode(' ', $text, $excerpt_length + 1);
$add_read_more = (count($words) > $excerpt_length);
} else {
$words = explode(' ', $text);
$add_read_more = true;
}
if ($add_read_more) {
if (count($words) > $excerpt_length)
array_pop($words);
$custom_read_more = str_replace('%permalink%', get_permalink(), $bfa_ata['custom_read_more']);
$custom_read_more = str_replace('%title%', the_title('','',FALSE), $custom_read_more);
array_push($words, $custom_read_more);
$text = implode(' ', $words);
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'bfa_wp_trim_excerpt');
starting from line 268.
But I do not like the behaviour to not print a link to the original article. Thus I replaced
PHP Code:
$add_read_more = (count($words) > $excerpt_length);
by
I think there should be an option to print the link to the original article even when the complete text has been printed on the excerpt page, because for example images will be left out on excerpts.
Cheers,
nightware
|