显示自定义帖子的正文文本

时间:2015-10-18 21:25:23

标签: php wordpress wordpress-plugin wordpress-theming

我使用PODS创建自定义帖子类型。我想在自定义模板中显示这些帖子类型。我已经能够显示标题,图像,但还没有找到显示身体内容的方法。我没有运气就试过get_the_content( $id )。有什么想法吗?

<?php
      $pod = pods( 'selectoffers' );
      $related = $pod->field( 'select' );
     if ( ! empty( $related ) ) {
        foreach ( $related as $rel ) {
          $id = $rel[ 'ID' ];?>
           <div class="col-lg-4">
              <div class="round-img img-circle" style="background-image:url('<?php echo pods_image_url(get_post_meta( $id, 'bilde', true ), $size = 'full'); ?>');"></div>
                 <h2><?php echo get_the_title( $id ); ?></h2>
                   <p> [[THIS IS WHERE I WANT TO ADD THE BODY]] </p>
                   <p><a class="btn btn-default" href="<?php $lenke = get_post_meta( $id, 'lenke', true );
                      echo esc_url( get_permalink( array_shift($lenke) ) ); ?>" role="button">Les mer &raquo;</a></p>
              </div><!-- /.col-lg-4 -->
            <?php
        } //end of foreach
     } //endif ! empty ( $related )
?>

1 个答案:

答案 0 :(得分:1)

使用以下代码使其工作:

$content_post = get_post($id);
$content = $content_post->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]&gt;', $content);
echo $content;