Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm forced to use manual excerpts on a number of my posts to integrate them with a shortcode plugin. However, this is interfering with how they're being displayed on an archive page (using a page template). Is there a way to force WordPress to display an automated excerpt (ie, the first 80 words) on one page template only?

share|improve this question
add comment

1 Answer 1

up vote 2 down vote accepted

You can utilize the wp_trim_excerpt filter. In your callback function that filters the the excerpt text, you can test for the presence of a certain template; then, if that template is being used, you can go ahead and alter the excerpt in any way that you see fit. In order to determine which template is being used, see this clever solution: get name of the current template file. Let me know if this helps or if you need more.

share|improve this answer
    
Hi @tollmanz, I can definitely do this (or even just use the built-in WordPress function, is_page_template(); I'm just not sure how to override the manual excerpt in the filter. –  daysrunaway Aug 22 '11 at 23:15
    
The wp_trim_excerpt is sent the manipulated text as the first parameter and the raw text as the second parameter. Are you comfortable working with filters? If so, look up wp_trim_excerpt in the core code. If not, I can help you along a little more. –  tollmanz Aug 22 '11 at 23:21
    
Thanks @tollmanz, it turns out I can just use the wp_trim_excerpt() function to get the abbreviated excerpt. –  daysrunaway Aug 25 '11 at 17:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.