Allow latex in wordpress excerpt

I’ve found some code below which allows you to write HTML in a WordPress excerpt.

Allow HTML in excerpt

I would like to write LaTeX in the excerpt as well (using Beautiful Maths from Jetpack).

Could anybody help me adapt the above code so that LaTeX will render in excerpts?

Note, to write LaTeX with Beautiful Maths, you begin the latex expression with $latex and end with $. E.g., $latex \frac{3}{2} $.

1 Answer
1

If I’m not mistaken, this could be as simple as

add_filter('get_the_excerpt', 'latex_markup');

if the Latex markup isn’t removed by another filter before that (it shouldn’t, I believe).
latex_markup is the function jetpack adds to the list of filters on the_content. It might get interesting when your latex code is at the edge of the excerpt and parts of it would get cut off, but if you can take care of that, you should be fine.

Leave a Comment