Combining the_excerpt with the_content

The key is to use user-defined excerpts, rather than auto-generated excerpts. For example: <div <?php post_class(); ?>> <?php // If post has defined excerpt, output it here if ( has_excerpt() ) { ?> <div class=”first-paragraph-excerpt”> <?php the_excerpt(); ?> </div> <?php } // Now output the content the_content(); ?> </div> <!– .post –> You’ll need to … Read more

Replace full content with an excerpt

Decide about the_excerpt() or the_content() with a conditional: is_singular(). You can use a plugin and filter the_content depending on the current page’s type: archive or singular. But you can use it in your theme too. add_filter( ‘the_content’, ‘t5_replace_content_with_excerpt’, 100 ); /** * Return excerpt if we are not on a singular post view. * * … Read more

Show read more link next to last word

The only thing that makes sense to me is that $text immediately after this line: $text = force_balance_tags($out); Has something that wpautop translates as a paragraph break– something like a double newline. Untested, but I would think that trim would clear it up. $text = trim($text) . $excerpt_end;

Display oEmbed in the_excerpt

Without knowing more about your theme I can only hazard a few guesses. What are you inputting as an excerpt, what is the current output you are seeing for your excerpt, and what is the expected output? Are you seeing the URL show up in the excerpt, or is it being stripped? Oembed Are you … Read more

Easy way to show excerpts of specific posts on a page

You need a couple of things. A shortcode handler, and a custom query: function wpse_186346_excerpt_length() { return 50; } function wpse_186346_excerpt( $atts ) { $atts = wp_parse_args( $atts, array( ‘posts_per_page’ => 2, // Any other default arguments ) ); // We don’t need paging, always save a query $atts[‘no_found_rows’] = true; // Create query based … Read more

Change excerpt length of first post

Use the current_post property of the WP_Query object: function new_excerpt_length($length) { global $wp_query; // assuming you are using the main query if ( 0 === $wp_query->current_post) return 50; else return 20; } The function may need further tweaks to avoid interfering with other queries in unintended ways, but that is the basic idea.

Can I use both a custom excerpt and a trimmed excerpt?

We can try to filter the excerpt through the get_the_excerpt filter. By default, if we have a manual excerpt, the manual excerpt will be used and not the automatically created excerpt which is created by the wp_trim_excerpt() function. We can alter this behavior. What we will do is, when we are inside the main query … Read more

Custom excerpt length filter doesn’t work

For anyone wondering, as custom excerpts don’t get trimmed by the excerpt_length filter hook, try adding this filter: function trim_custom_excerpt($excerpt) { if (has_excerpt()) { $excerpt = wp_trim_words(get_the_excerpt(), apply_filters(“excerpt_length”, 55)); } return $excerpt; } add_filter(“the_excerpt”, “trim_custom_excerpt”, 999);

How to disable automatic excerpt generation *in admin*?

Just illustrating this in full effect here with the filters and functions for both the adding of custom column and testing for excerpt existence. Note, I’ve purposely ripped the guts out of has_excerpt to show you in effect what is occurring under the hood. You can use !has_excerpt in its place. add_filter(‘the_excerpt’, ‘no_excerpt’); add_filter(‘manage_posts_columns’ , … Read more