![](/img/trans.png)
[英]How to print page title of parent and up to one child only in WordPress
[英]Display child pages in Wordpress home page with thumbnail, title and page limit
我試圖在子頁面上顯示縮略圖,標題和頁面限制 ,但我不知道該如何編碼。 請幫我解決它。
<?php
$ancestor_id=29;
$nbpages = 2;
$pagesd = wp_list_pages(array(
"child_of" => $ancestor_id,
"include" => $incl,
"link_before" => "",
"title_li" => "",
"sort_column" =>
"menu_order"));
?>
一起去吧。 應該起作用:1.檢索具有父$ ancestor_id的所有頁面。2.循環瀏覽結果並回顯頁面標題和縮略圖。
$ancestor_id = 29;
$pg_args = array(
'sort_order' => 'asc',
'sort_column' => 'post_title',
'hierarchical' => 1,
'exclude' => '',
'include' => '',
'meta_key' => '',
'meta_value' => '',
'authors' => '',
'child_of' => 0,
'parent' => $ancestor_id,
'exclude_tree' => '',
'number' => '',
'offset' => 0,
'post_type' => 'page',
'post_status' => 'publish'
);
$pages = get_pages($pg_args);
foreach($pages as $page){
echo $page->post_title;
echo get_the_post_thumbnail($page);
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.