gpt4 book ai didi

wordpress - get_pages( array( 'child_of' => $post->ID ) 不显示所有 child

转载 作者:行者123 更新时间:2023-12-03 17:05:30 26 4
gpt4 key购买 nike

我对 wordpress 很陌生,想知道是否有人可以对这段代码有所了解。
我正在尝试在其父页面上列出所有子页面,这是删除了一些 html 的代码:

<?php
$mypages = get_pages( array( 'child_of' => $post->ID ) );

foreach( $mypages as $page ) {
$content = $page->post_content;
if ( ! $content ) // Check for empty page
continue;

$content = apply_filters( 'the_content', $content );
?>

<p style="color: white; text-transform: uppercase;"><?php echo $page->post_title; ?></p>

<?php
}
?>

代码有效,并显示正确的子页面 - 但不是全部。显示了 7 个最旧的帖子,但没有显示我本周创建的最新页面。我已经检查并仔细检查所有新旧页面在各个方面都相同 - 相同的模板、相同的父页面、相同的创建者、相同的订单号,并且都已发布。任何人都知道我可能做错了什么?

最佳答案

试试下面的代码:

$args = array('child_of' => $post->ID,'sort_order' => 'desc',
'sort_column' => 'ID',
);

关于wordpress - get_pages( array( 'child_of' => $post->ID ) 不显示所有 child ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42209958/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com