I'm trying to display multiple pages as a category posts pages.
<?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
}
?>
I have this, but this code is showing me the whole content of each page, I need to show like a post with the "read more" link and small content. Any idea? thanks
use below code :
<?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
}
?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.