Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Excerpts, Read more, Pagination (http://forum.bytesforall.com/forumdisplay.php?f=20)
-   -   Bug: Excerpts in Atahualpa (http://forum.bytesforall.com/showthread.php?t=6474)

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
PHP Code:

$add_read_more true

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

Fux May 3, 2010 06:12 AM

Yeah, the dropping-the-last-word-bug is really annoying. Will this be fixed in the next version?

babspace May 17, 2010 10:09 AM

Thank you!!!!!

I've been going slightly batty trying to figure out why all of my manual excerpts were of random (shortened) lengths. It didn't dawn on me, until now, that they were all missing the last word. :)

I've popped your code in and all is well.

Thanks again!


All times are GMT -6. The time now is 03:38 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.