Remove more or […] text from short post

The codex is your friend and should be your first stop 🙂 The […] is added by the_excerpt(). There is a filter supplied called the excerpt_more filter that is specifically included to customize the read more text after the excerpt To remove the […] after the excerpt text, you can do the following function new_excerpt_more( … Read more

How to end the excerpt with a sentence rather than a word?

This requires PHP 5.3+ (WP requires PHP 5.2.4+) add_filter(‘get_the_excerpt’, ‘end_with_sentence’); function end_with_sentence($excerpt) { $allowed_end = array(‘.’, ‘!’, ‘?’, ‘…’); $exc = explode( ‘ ‘, $excerpt ); $found = false; $last=””; while ( ! $found && ! empty($exc) ) { $last = array_pop($exc); $end = strrev( $last ); $found = in_array( $end{0}, $allowed_end ); } return … Read more

GET the excerpt by ID

Hi @Robin I. Knight: I view get_the_excerpt() as a function with legacy design. As WordPress usage has grown there are many newer use-cases where it doesn’t fit but where the newer functions for getting different data do. One example is the now frequent use of an $args array of function options. But it’s easy to … Read more

Allow HTML in excerpt

COMPLETE GUIDE TO EXCERPTS I’ve recently answered a few questions regarding excerpts, so I’m going to give a detailed explanation covering as much as I can. PREFACE There seems to be a couple of questions arising from this answer on where the code should go, and the answer is, it is really up to you … Read more