How Can A Plugin Hook Itself To the End of Every Excerpt?

So far, I’ve been able to only consistently hook the_content, appending my plugin at the end. How can I test if the displayed article is not the_content, but an excerpt, and hook my plugin after every the_excerpt? 1 Answer 1 From the codex there are a couple of possible filters for you to try: get_the_excerpt … Read more

Append Text to $post->post_excerpt

I’m trying to add some text after a product description in WooCommerce which uses the $post->post_excerpt. Currently I’m using the following code: add_action( ‘woocommerce_single_product_summary’, ‘d4tw_show_dimensions’, 20 ); function d4tw_show_dimensions() { global $product; $dimensions = $product->get_dimensions(); if ( ! empty( $dimensions ) ) { echo ‘<span class=”dimensions”> Length: ‘ . $dimensions . ‘</span>’; } } This … Read more

adjust the_excerpt based on template page

How can I write conditions to adjust the_excerpt on different pages? For example on my page-products.php page I want the_excerpt to be let’s say 40. function custom_excerpt_length( $length ) { return 20; } add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 ); Is it if and else conditions to make that happen? 1 Answer 1 You can add it … Read more

How do I filter get_the_excerpt() but keep all of its functionality intact?

I have a custom meta field that I want to display as my excerpt. I use a filter that does this for me: add_filter( ‘get_the_excerpt’, function($output){ $output=get_post_meta(get_the_ID(), ‘my_meta_field’, true); return $output; }); Now whenever I use get_the_excerpt() or the_excerpt() inside of the loop I get the content of my_meta_field. But since WP 4.5.0 get_the_excerpt() accepts … Read more

Extremely slow pageload for long post when using the_content?

My WordPress site has quite a few long posts that slow down page loading time exponentially. This only happens when using the post_content, for example, when using the the_content() and get_the_excerpt() functions. I ran some tests with the Query Monitor plugin. Load time is in addition to the page’s base loading time without the_content(). . … Read more

How to link up “read more” on excerpts hack from WP Recipies

I found the code on the WP Recipies page to force excerpts on the home page: function my_excerpts($content = false) { // If is the home page, an archive, or search results if(is_front_page() || is_archive() || is_search()) : global $post; $content = $post->post_excerpt; // If an excerpt is set in the Optional Excerpt box if($content) … Read more