admin管理员组文章数量:1425666
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
本文标签: Shortcode doesn39t display in custom post type
版权声明:本文标题:Shortcode doesn't display in custom post type 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745418947a2657816.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
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