猿问

在 Wordpress 主页中显示带有缩略图、标题和页面限制的子页面

我试图在我的 Wordpress 主页上显示带有缩略图、标题和页面限制的子页面,但我不知道如何编码。请帮我解决它。


<?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"));

?>


红颜莎娜
浏览 154回答 1
1回答

慕尼黑8549860

试试这个。应该可以: 1. 检索所有具有父 $ancestor_id 的页面 2. 循环遍历结果并回显页面标题和缩略图。&nbsp;$ancestor_id = 29;&nbsp;$pg_args = array(&nbsp; &nbsp; 'sort_order' => 'asc',&nbsp; &nbsp; 'sort_column' => 'post_title',&nbsp; &nbsp; 'hierarchical' => 1,&nbsp; &nbsp; 'exclude' => '',&nbsp; &nbsp; 'include' => '',&nbsp; &nbsp; 'meta_key' => '',&nbsp; &nbsp; 'meta_value' => '',&nbsp; &nbsp; 'authors' => '',&nbsp; &nbsp; 'child_of' => 0,&nbsp; &nbsp; 'parent' => $ancestor_id,&nbsp; &nbsp; 'exclude_tree' => '',&nbsp; &nbsp; 'number' => '',&nbsp; &nbsp; 'offset' => 0,&nbsp; &nbsp; 'post_type' => 'page',&nbsp; &nbsp; 'post_status' => 'publish');$pages = get_pages($pg_args);&nbsp; &nbsp; foreach($pages as $page){&nbsp; &nbsp; &nbsp; &nbsp; echo $page->post_title;&nbsp; &nbsp; &nbsp; &nbsp; echo get_the_post_thumbnail($page);&nbsp; &nbsp; }
随时随地看视频慕课网APP
我要回答