WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've been racking my brain on this. Here is a shortcode loop I've created to display a specific post type:

    function faq_shortcode($atts, $content = NULL) {
            'faq_topic' => '',
            'faq_tag'   => '',
            'faq_id'    => '',
            'limit'     => '10',
        ), $atts));
        $faq_topic = preg_replace('~&#x0*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $faq_topic);
        $faq_tag = preg_replace('~&#x0*([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $faq_tag);
            $faqs = new WP_Query(array(
                'p'                 => ''.$faq_id.'',
                'faq-topic'         => ''.$faq_topic.'',
                'faq-tags'          => ''.$faq_tag.'',
                'post_type'         =>  'question',
                'posts_per_page'    =>  ''.$limit.'',
                'orderby'           =>  'menu_order',
                'order'             =>  'ASC'
            $displayfaq= '<div class="faq_list">';
                while ($faqs->have_posts()) : $faqs->the_post();
                $displayfaq .= '<div class="single_faq">';
                $displayfaq .= '<h3 class="faq_question">'.get_the_title().'</h3>';
                $displayfaq .= '<p class="faq_answer">'.get_the_content().'</p>';
                $displayfaq .= '</div>';
            $displayfaq .= '</div>';
        return $displayfaq;


within one of those loops there is a post that has a shortcode being used

function emailbot_ssc($atts, $content = null) {
        extract( shortcode_atts( array(
        'address' => '',
            ), $atts ) );
        echo '<a href="mailto:'.antispambot($atts['address']).'" title="email us" target="_blank" rel="nofollow">'.$atts['address'].'</a>';
        $email_ssc = ob_get_clean();
        return $email_ssc;
add_shortcode("email", "emailbot_ssc");

the FAQ loop (code item #1) isn't parsing the shortcode. It just displays it raw.

share|improve this question
up vote 5 down vote accepted

get_the_content() does not have the the_content filters applied to it, which is where do_shortcode() is hooked in. Those filters are only applied in the_content(). Those two functions are not simply get/echo versions of each other. get_the_content() is lower level.

This is an anomaly in the API, and is that way for historical reasons. For instance, get_the_title() applies the the_title filters.

If you want the whole the_content filter stack applied, do:

apply_filters( 'the_content', get_the_content() )

If you only want shortcodes applied, do:

do_shortcode( get_the_content() )
share|improve this answer
That's what I assumed, and doing that doesn't seem to make a difference. If I put it outside that loop it doesn't chance anything, and if I put the it in the loop itself the content in the shortcode disappears completely. – Norcross Feb 23 '11 at 3:43
Some example code. – Mark Jaquith Feb 23 '11 at 5:17
That was it. I also realized I wasn't actually calling the 2nd shortcode correctly. – Norcross Feb 23 '11 at 8:16

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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