Site logo

Archived topic

Excerpt length in Elementor

7 replies · Started by Seppo Puusa on February 28, 2017

Viewing posts 1–8 of 8

I bought GP Pro to work with Elementor. So far the theme is fantastic, but I ran into a problem when using Elementor. In GP, I set the excerpt length to 55 words, which is ok for the blog page. But I want to feature a few categories on the home page, which I can easily do with Elementor. The problem I'm running into is that the excerpt length set in GP takes precedence over the setting in Elementor. I'd like to reduce the excerpt length to 10 or 20 words on the home page, but the setting in Elementor has no effect.

Any idea on how to get over this?

I've actually spoken the Elementor devs about this.

They're using the excerpt_length filter, which is a global filter inside WordPress.

Instead, they should be building their own excerpt function as I did in WP Show Posts.

Right now, the GP excerpt length overwrites the Elementor length, as it should in my opinion. If it was the other way around, whatever length you have set in Elementor would apply to the GP blog, archives, categories etc..

You can tell GP to take a back seat to Elementor like this:

add_action( 'after_setup_theme','tu_change_excerpt_length' );
function tu_change_excerpt_length() {
    remove_filter( 'excerpt_length', 'generate_excerpt_length', 999 );
    remove_filter( 'excerpt_length', 'generate_excerpt_length', 20 );
    add_filter( 'excerpt_length', 'generate_excerpt_length', 15 );
}

Thanks for the reply. I'll wait for the Elementor guys to provide a solution to this from their end. I agree that the settings in GP should take priority.

Hopefully they decide to. I suggested they use the same method I did in WPSP, so we'll see.

where I paste that code, I have the same problem

it doesn't work for me

This archived topic is closed to new replies.