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 »

[SOLVED] [BUGFIX 3.4.1->3.4.6] Getting Configure Excerpts to work in all cases


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 Sep 10, 2009, 07:08 PM
juggledad's Avatar
juggledad
 
22,244 posts · Mar 2009
OSX 10.8.5 WP 3.8.x Atahualpa 3.7.x Safari 6.x Firefox 25 XP
There are two ways to have excerpts using Atahualpa (1) Add an excerpt in the post (dashboard->Posts->Edit->Excerpt) or (2) have Atahualpa create one using the first X number of words in the post (ATO->Configure EXCERPTS->Excerpt length)

When you use method (2) Atahualpa will follow the excerpt with ATO->Configure EXCERPTS->Custom read more, but with option (1) it will not.

the following patch will allow the 'Custom read more' to show up in both cases.

Edit functions.php and locate the following code
in 3.4.1 it should be lines 243-266
in 3.4.2 it should be lines 250-273
HTML 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);
		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');
Replace that code with the following
HTML 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');
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #2  
Old Nov 4, 2009, 04:43 PM
CasTex
 
4 posts · Nov 2009
Thanks for the fix .

Last edited by CasTex; Nov 6, 2009 at 05:18 PM.
  #3  
Old Nov 8, 2009, 05:36 PM
juggledad's Avatar
juggledad
 
22,244 posts · Mar 2009
OSX 10.8.5 WP 3.8.x Atahualpa 3.7.x Safari 6.x Firefox 25 XP
I discovered a case that wasn't covered by the previous fix. In reworking it, I've discovered a bug/feature with the standard wordpress code. It all has to do with what do you count as a word? Should HTML that is embedded in a post be part of the excerpt word count? If not, why not? What about shortcodes? If not, couldn't you argue that they just shouldn't be allowed in posts at all?

What if a post has a short code and that short code generates a bunch of text, should that text be part of the wordcount or not? it gets messy.

At any rate, what this change does is
1) use a manual excerpt if it exists.
2) if there is a 'teaser' use that
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.

This fix is for 3.4.4
1) Down load the attached file and unzip it.
2) rename your current 'functions.php', in the atahualpa folder, to 'functions_old.php'
3) copy the new 'functions.php' to your atahualpa folder
that's it
Attached Files
File Type: zip functions.php.zip (7.3 KB, 804 views)
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support

Last edited by juggledad; Apr 1, 2011 at 04:31 AM.

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Can't configure theme options - I can only Reset ALL! AndrewSw New Versions, & Updating 7 Nov 4, 2009 01:13 PM
[SOLVED] I want to configure my WordPress blog. Xarzu Installing & running WordPress 3 Oct 27, 2009 04:50 AM
Atahualpa 3.4 : EXCERPTS new option to read the full post after [...] does not work benoit Excerpts, Read more, Pagination 2 Jul 9, 2009 06:45 PM
Excerpts on home page don't work kennfusion Excerpts, Read more, Pagination 1 Jun 7, 2009 10:22 AM
[SOLVED] Excerpts on home page don't work juggledad Excerpts, Read more, Pagination 1 May 31, 2009 06:14 PM


All times are GMT -6. The time now is 01:59 AM.


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