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.

  • So that's how you do it! I've been toying with that off and on for a while now trying to figure out how to use LaTeX.
    – Cedon
    Commented Jan 15, 2018 at 22:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.