我正在尝试将多个页面显示为类别发布页面。
<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
$content = $page->post_content;
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content );
?>
<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
<div class="entry">
<?php echo $content; ?>
<?php echo $page->post_title; ?>
<?php if(has_post_thumbnail()){ ?>
<?php the_post_thumbnail('featured');?>
<?php } ?>
</div>
<?php
}
?>
我有这个,但是这段代码向我展示了每个页面的全部内容,我需要像一个帖子一样显示“阅读更多”链接和小内容。任何的想法?感谢
答案 0 :(得分:0)
使用以下代码:
<?php
$mypages = get_pages( array( 'child_of' => $post->ID, 'sort_column' => 'post_date', 'sort_order' => 'desc' ) );
foreach( $mypages as $page ) {
$content = $page->post_content;
if ( ! $content ) // Check for empty page
continue;
$content = apply_filters( 'the_content', $content );
?>
<h2><a href="<?php echo get_page_link( $page->ID ); ?>"><?php echo $page->post_title; ?></a></h2>
<div class="entry">
<?php echo $page->post_title; ?>
<a href="<?php echo get_page_link( $page->ID ); ?>">read more</a>
<?php if(has_post_thumbnail()){ ?>
<?php the_post_thumbnail('featured');?>
<?php } ?>
</div>
<?php
}
?>