2015-01-05 48 views
0

我想在一个div和一个新的div的内容在一个自定义布局中使用后图像/缩略图。尝试在图片显示后获取内容时遇到问题。WordPress的 - 获取新的div的帖子内容

这个作品在得到我的文章标题和图像到所需的布局,但没有显示字幕相关的

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> 
<header class="entry-header"> 
    <?php the_title('<h3 class="title no-underline">', '</h3>'); ?> 
</header><!-- .entry-header --> 

<div class="news-images"> 
<div id="news-swiper" class="swiper-container"> 
    <div class="swiper-wrapper"> 
     <div class="swiper-slide" data-caption=""> 
      <div class="entry-content news-item-copy"> 
       <?php 
       $get_description = get_post(get_post_thumbnail_id())->post_excerpt; 
       the_post_thumbnail(); 
       if(!empty($get_description)){//If description is not empty show the div 
       echo '<div class="image-captions">' . get_post(get_post_thumbnail_id())->post_excerpt . '</div>'; 
       } 
       ?> 
      </div> 
     </div> 
    </div> 
</div> 
</div> 

<div class="news-sharing"> 
    <?php wpsocialite_markup(); ?> 
</div> 

图像这是我试图获得剩下的文章内容和有问题。

<div class="news-item-copy">  
<?php the_excerpt(); ?> 
    <?php 
     wp_link_pages(array(
      'before' => '<div class="page-links">' . __('Pages:', 'themeName'), 
      'after' => '</div>', 
     )); 
    ?> 
</div> 

</article> 

我用<?php the_excerpt(); ?>只是在它需要的位置,但很明显,因为这是它没有显示完整的内容摘录内容的地方。这个想法是将带有标题的精选图像/缩略图置于顶部,中间的社交分享以及最后的内容。

回答

0

我想你要替换the_content the_excerpt()()

http://codex.wordpress.org/Function_Reference/the_content

+0

使用'the_content()'获取的全部内容该帖子包含了我不想查找的图片,因为我已经有了一个调用上面所需图片的函数。谢谢你的意见。 –

+0

我会考虑使用自定义字段插件。您可以将自定义字段中的图像和其他内容分开。 https://wordpress.org/plugins/advanced-custom-fields/ – hakeemon

0

你再通过缩略图ID里面get_post,你必须通过帖子的ID在该功能

没有缩略图ID $ get_description = get_post(get_post_thumbnail_id()) - > post_excerpt;

或者简单地echo the_content();将打印的帖子内容&,如果你想显示一些有限的内容 然后用

substr(the_content(),0,150)这将只显示150字

相关问题