WordPress is a great blogging platform and overall CMS. Part of its utility comes from its in-built capability to display excerpts from posts and pages, which makes displaying search results and archives much more elegant.
This is, however, not without its flaws. One the most common problem with excerpts is WordPress that WordPress shortcodes don’t work in excerpts.
Fortunately, WordPress’ Shortcode API has within it the capability of easily and quickly fixing this issue.
Below is the default PHP statement to display a post’s excerpt in WordPress:
< ? php the_excerpt(); ?>
The problem with the_excerpt() function is that it echoes the excerpt directly to the screen without interpretation. This causes the shortcode itself to display in the excerpt rather than the code it was calling.
In order to have NextGen Gallery entries appear in the post excerpts, simply replace that line wherever it occurs in your blog’s theme files with the following:
< ? php echo do_shortcode(get_the_excerpt()); ?>
The do_shortcode() function actually runs the shortcodes and returns their results as a string. Hence, it will allow your NextGEN Galleries – and anything other shortcodes – to display properly within post excerpts.