I use the Leaf theme
and I can’t seem to format the home page excerpts.
I tried plugins and fiddling around with the theme-functions.php file but to no avail.
I don’t need a lot of fancy stuff in the excerpts just a bit of formatting, nothing more.
That should be possible, right?
The excerpt is created in -> wp-includes/formatting.php with this code:
To change the behavior WP exhibits normally for excerpts, first remove this function (not from the core code, but using remove_filter() by placing this in your functions.php:
Next, you’ll need to create a new function to control excerpts so you can copy the above function from WP core as a starting point. Name it something different. Then, change what you need. For example, if you want to allow the tag in your excerpts, you would modify this line:
to this:
If you need more than one allowed html tag, list them after . So your new function in your functions.php might look like:
And then finally, you need to tell WP to filter your excerpt through your new function. Add the filter like this in functions.php: