Making oEmbed work on the excerpt field
Not entirely sure it is supposed to be used like this, but by analogue with the_content try this: add_filter(‘the_excerpt’, array($wp_embed, ‘autoembed’), 9);
Not entirely sure it is supposed to be used like this, but by analogue with the_content try this: add_filter(‘the_excerpt’, array($wp_embed, ‘autoembed’), 9);
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
Changing the word count on the home page is easy: if( is_home() ) add_filter( ‘excerpt_length’, create_function( ”, ‘return 300;’ ) ); Just replicate that code and change the conditional check to add this to other pages. The other option is to just insert the code on the template page (home.php, tag.php, etc.), so you know … Read more
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
You can just remove the filter before calling the_excerpt and then add it back afterwards… remove_filter(‘excerpt_more’,’new_excerpt_more’); the_excerpt(); add_filter(‘excerpt_more’, ‘new_excerpt_more’);
Because I am very particular about how to do things in WordPress when it comes to looping, I couldn’t help but want to post a better way to do the above loop in your question as seeing the way you’ve done it looks like a lot of unnecessary work for yourself. You already answered your … Read more
A more reliable way would be to filter the excerpt and to explode the string into an array, remove the first two key/value pairs from the array and then return your string add_filter( ‘wp_trim_excerpt’, function ( $text ) { // Make sure we have a text if ( !$text ) return $text; $text = ltrim( … Read more
The post_excerpt value is empty because you have no explicit excerpts for your posts. While the_excerpt() does generate an excerpt from the posts content if the post excerpt is empty, the function wp_get_recent_posts(), which is basically a wrapper for get_posts(), doesn’t.
Perhaps a conditional statement like the following will work. The logic is: “If the post has an explicit excerpt, add a read more link. Otherwise, use default excerpt behavior.” if($post->post_excerpt) { the_excerpt(); echo ‘<a href=”‘.get_permalink().'”>Read More</a>’; } else { the_excerpt(); } You can use this in combination with Gavin’s suggestion to unify the appearance of … Read more
Regenerate auto excerpts after updating many posts