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>
<div class="prxpart">
<h1 class="prxttl">À partir de <br />
<?php
$prx = ( empty( $hotel_data['prx'] ) ) ? '???' : $hotel_data['prx'];
echo $prx; ?> € / NUIT
</h1>
</div>
</header><a id="pres"></a>
<div class="singletxt">
<?php
$content = get_the_content();
echo $content; ?>
<a id="pho"></a>
<a id="chm"></a>
<a id="cprx"></a>
</div>
<?php else :
echo 'Pas de hotels pour l\'instant';
endif;?>
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>
<div class="prxpart">
<h1 class="prxttl">À partir de <br />
<?php
$prx = ( empty( $hotel_data['prx'] ) ) ? '???' : $hotel_data['prx'];
echo $prx; ?> € / NUIT
</h1>
</div>
</header><a id="pres"></a>
<div class="singletxt">
<?php
$content = get_the_content();
echo $content; ?>
<a id="pho"></a>
<a id="chm"></a>
<a id="cprx"></a>
</div>
<?php else :
echo 'Pas de hotels pour l\'instant';
endif;?>
Share
Improve this question
edited Jun 10, 2019 at 17:27
RyanS
1256 bronze badges
asked Mar 28, 2015 at 15:14
Carl WillisCarl Willis
3051 gold badge2 silver badges11 bronze badges
2
|
1 Answer
Reset to default 2You could just
echo do_shortcode( $content );
Function Reference/do shortcode
the_content
doesn't render shortcodes? shortcodes not working withget_the_content
is expected, as is noted in the documentation for that function. – Milo Commented Mar 28, 2015 at 15:35