【发布时间】:2014-10-24 15:50:24
【问题描述】:
不确定是否有人可以提供帮助,但我在 WordPress 网站上显示页面摘录时遇到问题。我已经看过这个页面 (How to display page excerpt in Wordpress) 但仍然无法让它工作。这是我正在使用的代码:
<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'meta_value' => 'C4News', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
$content = $page->post_content;
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content );
?>
<div class="page-excerpt-panel">
<a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo get_the_post_thumbnail( $page->ID, 'thumbnail', array('class' => 'page-listing-thumbnail')); ?></a>
<span class="page-excerpt-text-panel"><span class="post-excerpt-title"><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></span><?php the_excerpt();?></span>
</div>
<?php
}
?>
我已经在我的 functions.php 文件中添加了两段代码 - (1) 启用 Pages 的手动摘录,以及 (2) 在摘录末尾使用自定义的“阅读更多”链接。在博客索引页面上一切正常(显示帖子缩略图、标题、手动摘录和自定义的“阅读更多”链接),但是当我尝试使用上述代码为页面列表复制相同的内容时,它仅显示缩略图、标题和“阅读更多”链接(没有摘录)。
问题可以看这里:http://www.retelevise.com/televisionnews/
但它适用于此处博客索引页面上的帖子:http://www.retelevise.com/blog/
请知道我做错了什么?谢谢。
【问题讨论】: