Different Excerpt Lengths For Posts & Archives

The PHP code in this free quick tip enables you to conditionally change the length of the excerpt.

Based on this question from a member of the Genesis community :

Looking to change the excerpt length. I’d like to have it as an if page id is this return x, else be x so the homepage can be different.

Here’s the code for your child themes functions.php file :

In the above example, the excerpt length will be set at 10 words if the post is in the travel category otherwise the excerpt length for all other posts is set at 100 words.

This code includes a ternary operator and conditional tag.

You will need to swap out the conditional tag with your own to suit your own requirements.

Assumes you have set excerpts in Genesis > Theme Settings > Content Archives.

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.