Currently in a wordpress template, if you use the code the_excerpt()
it will display the first 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:
Is there a filter hook or other known method to include html easily without hacks?
All help is appreciated! Cheers.
To add the excerpt on your blog post, go to Posts >> Add New or simply edit your existing post. Now, on the right options panel, click on the Excerpt option and add the excerpt for your posts. Once done, click on Publish/Update button to save your changes.
Displays the excerpt of the current post after applying several filters to it including auto-p formatting which turns double line-breaks into HTML paragraphs. It uses get_the_excerpt() to first generate a trimmed-down version of the full post content should there not be an explicit excerpt for the post.
Insert a Read More tag This method allows you to choose which posts have excerpts, and you can make the excerpt any length you want. If you're using the Visual editor, place your cursor at the end of the text that you want to be the excerpt. Click Insert Read More tag in the toolbar.
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With