Wpautop stops working after get_the_excerpt

wpautop has got to be my least favorite part of working with WordPress. Just when everything else is working, it sticks its fingers into everything…

The problem has to do with filter priority, as you noted earlier. In the case of the excerpt, we’re interested in the filter get_the_excerpt. I haven’t been able to figure out what priority it has normally, and I also tried changing its priority. I succeeded, but it didn’t affect my wpautop problem.

Instead of messing with filter priorities, I duplicated the functionality of get_the_excerpt in my shortcode. It would be better if I found a general solution, but luckily I don’t have to use the excerpt in shortcodes very often.

Here is the code that worked for me:

while ($latest->have_posts()): $latest->the_post();
    //$excerpt = get_the_excerpt(); // This doesn't work

    // Let's do it like the get_the_excerpt filter function in the core does
    // Once we get the excerpt by alternate means, everything else works again
    // See get_the_excerpt in /wp-includes/post-template.php
    $post = get_post();
    $excerpt = $post->post_excerpt;

    // Choose what to do based on whether it's empty or not
    if ($excerpt != '') echo $excerpt;
    else echo 'some fallback';
endwhile;