Reduce excerpts length

Hi Movin,

I’m tryin to reduce the excertps lenght for showing only the excerpt in all categories and posts even if the text length of the post is only three words.

So i used this on my functions.php inside my child theme :

function custom_excerpt_length( $length ) {
return 3;
}
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );

but it’s not working.

I’ve had a look in your content.php file but I see you’ve used a custom function to print the excerpts so I don’t know how to resolve.

Many thank for your attention, this is the website if you want to take a look too : www.matteovalentini.com

Greetings,
Francesco.

Hi Francesco,

I hope you are well today and thank you for your question.

The following code that you have shared above is working fine on my test site using latest version of Activello theme.

function custom_excerpt_length( $length ) {
return 3;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

Would you mind if i log in to your site and do some troubleshooting? If this is ok then could you please share me your site log in details privately by checking the option “Set as private reply” when replying to this topic?

Kind Regards,
Movin

Hi Movin,

thank you for your answer, I’m tryin to fix this in local and I’ve seen that is working but the real request is to have the excerpt even if I don’t write any word inside each post.

My client would see only the post thumbnail in each post and clicking on the image see the gallery.

I’ve noticed that if you don’t write anything inside a post you alway see the post thumbnail and the gallery even if you’ve set Wordpress to show the excerpt so I’m thinking is not a problem of excerpt length because setting it to 3 with the code above is actually working fine in localhost but where is not present text in the post it’s not working.

I hope I’ve explained well the question and many thanks again for your attention.

Best Regards,
Francesco

If you are not adding any content in the post content then to display excerpt on home page please add the excerpt text in the excerpt field of post.

Hi Movin,

thank you very much for your answer, including a specific function in my functions.php child theme’s file I resolved.
This is the link on the codex

Sorry for my ignorance about the excerpts and thank you very much again.

Best regards,
Francesco

You are most welcome here :slight_smile: