How to get excerpt correctly formatted

wp_trim_excerpt() calls wp_trim_words() which applies wp_strip_all_tags() to the excerpt. The <br> tag is removed and not replaced with anything. Not sure if this is feasible, but having a space after a colon is grammatically correct, and adding it to the original content would not affect the HTML, e.g.: <p>My new question is: <br>why words are … Read more

The excerpt: Display text OR image OR video

I would encourage you to consider using post formats. You can see my answer to a similar question about altering the “Read More” text, but it would apply similarly to you. For the video portion, you might want to create a custom field to hold the video URL, but otherwise, I imagine this would be … Read more

Different ‘read more’ links

How about using condition to change the readmore links. Here is an sample code which returns a different read more text based upon the category of post. You should read the official codex page to know more about other conditional tags you can use in wordpress. Usage – put this code into your theme’s functions.php … Read more

Change behavior depending on content length

We need two functions in the theme’s functions.php: One function checking the length of the content to adjust the title. Another one to print the formatted post content in case the first function returns TRUE. Let’s start with the first function. This is rather simple because we solved that already. 🙂 if ( ! function_exists( … Read more

Allow latex in wordpress excerpt

If I’m not mistaken, this could be as simple as add_filter(‘get_the_excerpt’, ‘latex_markup’); if the Latex markup isn’t removed by another filter before that (it shouldn’t, I believe). latex_markup is the function jetpack adds to the list of filters on the_content. It might get interesting when your latex code is at the edge of the excerpt … Read more

can hyperlinks be displayed in excerpts?

WordPress uses the filter wp_trim_excerpt to strip the tags. You can remove the filter and create your own which will allow the links: <?php function new_wp_trim_excerpt($text) { $raw_excerpt = $text; if ( ” == $text ) { $text = get_the_content(”); $text = strip_shortcodes( $text ); $text = apply_filters(‘the_content’, $text); $text = str_replace(‘]]>’, ‘]]>’, $text); $text … Read more