2015-10-18 66 views
0

我使用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) 
?> 
+0

the_content()是你想要的功能,但你为什么不使用循环? – David

+0

如果已尝试both_content()和the_content($ id),但它们都不返回任何内容。不使用循环是什么意思? – janlindso

+0

如果你是谷歌WP循环,你应该找到循环中的负载,这基本上是一组函数来创建模板。 the_content只能在循环中使用(你需要这个函数有几个原因) – David

回答

1

制造它的工作使用下面的代码:

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