php - WP - 检索当前页面的子页面
问题描述
我有一些依赖于合作伙伴 CPT 的 cpt 帖子。我想从当前父 cpt 检索子 cpt,但此代码检索 cpt 中的所有页面(其他父和子也是)。怎么了?
if (is_singular('conversacion-ingles')) {
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'show_all_children');
function show_all_children(){
$child_args = array(
'post_parent' => $post->ID, // The parent id.
'post_type' => 'conversacion-ingles',
'post_status' => 'publish',
'order' => 'ASC'
);
$children = get_children( $child_args );
if ( empty($children) ) return;
echo '<div class="children">';
echo '<ul class="children level-'.$current_level.'-children">';
foreach ($children as $child) {
echo '<li>';
echo '<a href="'.get_permalink($child->ID).'">';
echo get_the_title($child->ID);
echo '</a>';
echo '</li>';
}
echo '</ul>';
echo '</div>';
}
}
解决方案
推荐阅读
- python - 将具有多级嵌套列表的不规则列表转换为列表列表
- class - 如何将自定义 CSS 类添加到
- AEM RTE 组件
- python - Blender 作为 Python 模块 Mac
- python - 实现可迭代的 jsonpickle 解码两次
- java - 我不确定为什么我的程序不断崩溃
- wordpress - 如何将一个站点页面数据获取到 WordPress 多站点中的另一个站点页面
- sql-server - SQL Server 复制数据库向导 -w/o- 登录提示错误 (SMO) 用户、组或角色“x”已存在于当前数据库中
- c++ - 将 boost 函数与 boost 绑定与地图一起使用
- javascript - 如果所选选项的值动态更改,则选择标签值不会更新
- c# - 无法加载文件或程序集或其依赖项之一,错误消息正在更改