开发者

How to include html tags within a wordpress excerpt?

Currently in a wordpress template, if you use the code the_excerpt() it will display the fir开发者_C百科st 55 words of a post and strips all html from the post.

I need to include <a href... tags in the excerpt so that links are still visible.

Existing methods include:

  1. Hacking the wordpress core - definitely not an option.
  2. using a plugin - don't want to use, it's dependent on the developer keeping the plugin up to date
  3. writing code within functions.php to re-write the excerpt filter. - I'd prefer not to use this as it might have to be changed in future versions of WP

Is there a filter hook or other known method to include html easily without hacks?

All help is appreciated! Cheers.


As I see it, you can only use method 2 and 3; both of them can be updated via WordPress' back-end with virtually no programming required which is ideal if you're going to be installing and using them on client sites.

Here's a tutorial with working code for method 3 -- http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/ and here's a plugin to use method 2 -- http://wordpress.org/extend/plugins/advanced-excerpt/


I use the following statement sometimes to get the first 55 words of a post content.

implode(' ', array_slice(explode(' ', get_the_content()), 0, 55));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜