javascript - 在 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"));
?>
解决方案
试试这个。应该可以: 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);
}
推荐阅读
- google-cloud-platform - BigQuery python 客户端使用 Streaming API 删除一些行
- c# - 如何理解不受 IO 限制的异步代码
- laravel - Laravel 多态多对多关系
- javascript - 我可以在 (function($){...}(jQuery)); 中使用 Ajax 提交请求吗?
- c - 警告 C4244:'function':从 'time_t' 转换为 'unsigned int',可能丢失数据'
- jenkins - 失败时在不同的奴隶上重新运行 Jenkins 作业
- android - 如何从我的应用程序中正确识别 AnkiDroid(或任何其他外部应用程序)的文件存储目录?
- upgrade - Xcart 应用升级包时出现错误
- sql - 对 bigquery 中的每一行进行分组
- python - 将变量数据显示为月份和年份