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)
-   -   Adding shortcode function for excerpts (http://forum.bytesforall.com/showthread.php?t=15049)

bswb97 Aug 9, 2011 11:14 AM

Adding shortcode function for excerpts
 
I want to use some shortcode functionality on excerpts posted on the home page. I know this can be a bit tricky, but this fellow claims to have figured it out:

http://www.mummey.org/2009/02/wordpr...de-an-excerpt/

Quote:

When displaying the post’s excerpt, Wordpress uses a function called the_excerpt(). Here it is in the default sandbox template:

HTML Code:

the_excerpt(''.__('Read More <span class="meta-nav">&raquo;</span>', 'sandbox').'') ;
The problem with the_excerpt is that is echoes the excerpt directly to the screen. In order to return the excerpt value as a string we need to use get_the_excerpt(). Next after checking the shortcode API, I discovered a function that will run all the shortcodes on a given string and return the output as a string, do_shortcode().

So all we need to do now is combine these two functions, and move it into the template:

HTML Code:

echo do_shortcode(get_the_excerpt());
And there it is!
I haven't been able to experiment with this too much because I wanted to know WHERE to place this before I potentially had to revert to backup files. He's saying move it into the template -- does that mean a Body HTML insert? Or should I write it directly into the index.php file, and if so, where?

juggledad Aug 9, 2011 11:27 AM

Actually you will have to look in bfa_post_parts.php and note that there are several ways that you can get an excerpt


All times are GMT -6. The time now is 02:56 PM.

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