Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » New Versions, & Updating » Old Version fixes and change logs »

BUGFIX 364-07: Correction to how Excerpts are processed


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Apr 1, 2011, 02:24 PM
juggledad's Avatar
juggledad
 
22,074 posts · Mar 2009
OSX 10.8.5 WP 3.8.x Atahualpa 3.7.x Safari 6.x Firefox 25 XP
The excerpt logic was changed in 3.4.5 but a error was introduced. If there was a 'teaser' (if a '<!--more-->' is present) on the page, it would be used in place of the excerpt. The following fix changes the logic so it works in this manner

When displaying a FULL POST, break at the teaser ('<!--more-->') otherwise display the full post.

When displaying EXCERPTS
1) use a manual excerpt if it exists.
2) if a 'teaser' ('<!--more-->') shows up BEFORE the 'excerpt length' (as defined at ATO->Configure EXCERPTS->Excerpt length) is met, break the page at the <!--more-->.
3) otherwise, create a excerpt based on the ATO excerpt word count - after stripping out all HTML except the things specified in 'Don't strip these tags' - but those 'words' (a word being a string seperated by a blank) count as part of the word count. i.e. the HTML not stripped will be part of the word count.

edit functions.php and replace lines 276-325 which are
HTML Code:
// Custom Excerpts 
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed

	global $bfa_ata, $post;

	if ( '' <> $text ) {
//  an excerpt exists, just stick on the 'custom read more' and we're done
		$words = preg_split("/\s+/", $text);
		$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;
	}

	$text = get_the_content('');
	$words = preg_split ("/\s+/", $text);
	$post_content = $post->post_content;
	$post_content_length = count(preg_split("/\s+/", $post_content));
 
	if (count($words) < $post_content_length) {	

//  use the teaser and its 'read more'
		$bfa_ata_more_tag_final = str_replace("%post-title%", the_title('', '', false), $bfa_ata['more_tag']);
		$text = the_content($bfa_ata_more_tag_final); 
		return $text;
	} else {

// Build the excerpt from the post 
		$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 = preg_split("/\s+/", $text, $excerpt_length + 1);

// this is to handle the case where the number of words 
// in the post equals the excerpt length
 		if ($post_content_length > $excerpt_length) {	
 			array_pop($words);	
  			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;
		}

	return $text;
}
with
HTML Code:
// Custom Excerpts 
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed

	global $bfa_ata, $post;

	if ( '' <> $text ) {
//  an manual excerpt exists, stick on the 'custom read more' and we're done
		$words = preg_split("/\s+/", $text);
		$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;
	}

	$text = get_the_content('');
	$words = preg_split ("/\s+/", $text);
	$post_content = $post->post_content;
	$post_content_length = count(preg_split("/\s+/", $post_content));

// Build the excerpt from the post 
	$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 = preg_split("/\s+/", $text, $excerpt_length + 1);

// this is to handle the case where the number of words 
// in the post equals the excerpt length

 	if ($post_content_length > $excerpt_length) {	
 		array_pop($words);	
//  		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;

	return $text;
}
or you can use the following attachment which has the correction already made. This correction also has the function.php fix from BUGFIX 364-05 included
functions.php.zip
__________________
If you like my help, please consider donating. I am happy to provide greater detail on this and other topics if you hire me. Please send detailed support requests to me as a private message, thank you.
Juggledad | Forum Moderator/Support

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
BUGFIX 364-06: Post Date does not work in 'FOOTER: xxxx' juggledad Old Version fixes and change logs 0 Mar 9, 2011 04:48 AM
BUGFIX 364-02: CSS Compression does not happen if 'Allow debugging?' is 'Yes' juggledad Old Version fixes and change logs 12 Mar 5, 2011 04:00 PM
BUGFIX 364-03: Background and Border not honored using page/cat centered juggledad Old Version fixes and change logs 7 Feb 27, 2011 10:35 PM
BUGFIX 364-05: No link to the full post shown on excerpt when post has no title juggledad Old Version fixes and change logs 0 Feb 21, 2011 03:49 PM
BUGFIX 364-04: Tagline will show when Overlay Blog TITLE over Header Image(s)? = yes juggledad Old Version fixes and change logs 0 Feb 19, 2011 05:09 PM


All times are GMT -6. The time now is 09:07 AM.


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