I created a custom post type, but when I add a shortcode for a slider, it doesn't show the slider it shows just the shortcode in text.

And, when I change get_the_content by the_content, it shows me just a little text like excerpt.

 <?php if ( have_posts() ) : the_post(); ?>
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
        <header class="singleheader">
        <div class="singlettlpart">
            <h1 class="singlettl"><?php the_title(); ?></h1>
            <?php $post_id = get_the_ID();
            $hotel_data = get_post_meta( $post_id, '_hotel', true );
            $adr = ( empty( $hotel_data['adr'] ) ) ? 'Aucune adresse trouvée' : $hotel_data['adr'];
            echo $adr; ?> <a href="#carte" class="cartelnk">(voir la carte)</a>
        <div class="prxpart">
            <h1 class="prxttl">À partir de <br />
                $prx = ( empty( $hotel_data['prx'] ) ) ? '???' : $hotel_data['prx'];
                echo $prx; ?> € / NUIT
        </header><a id="pres"></a>
        <div class="singletxt">
                $content = get_the_content();
                echo $content; ?>
                <a id="pho"></a>
                <a id="chm"></a>
                <a id="cprx"></a>
    <?php else :
    echo 'Pas de hotels pour l\'instant';
  • so you're saying using the_content doesn't render shortcodes? shortcodes not working with get_the_content is expected, as is noted in the documentation for that function.
    – Milo
    Mar 28, 2015 at 15:35
  • oh ok so with get_the_content i can't make shortcode work. but when i use the_content it shows just a little of text like excerpt, i don't know why. Mar 28, 2015 at 15:42

1 Answer 1


You could just

echo do_shortcode( $content );

Function Reference/do shortcode

  • hhhhhhhhh seriously i don't know with which ink did you write your answer but its work although i have tried this 2 times before i don't know why it doesn't work for me before. Thank you. Mar 28, 2015 at 16:37

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.