我正在使用下面的一段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