我正在使用下面的一段php来获取页面以显示其子页面的内容。 我只想显示前10个结果,然后显示'显示更多'按钮。 我试图通过post_excerpt(L6)替换post_content,但没有奏效。我错过了什么?在wordpress中的几个页面上显示get_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; ?></div>
<?php
}
?>
有你试过通过for循环运行它,并将循环的长度设置为10?或者,如果数据以页面数组的形式返回,则使用array_slice?不知道我是否理解你的问题。 – 2014-09-26 19:59:59
嗯,但在这种情况下,我将结果限制在前10个结果中,但没有显示其余结果的按钮,不是? – mrtnmgs 2014-09-26 20:52:12