php修改主页上的菜单,在page.php上更改子菜单的顺序

在我的模板的page.php中, 我获得了子菜单的以下代码。

$parent = wp_get_post_parent_id($post->ID);

$args = array(

'post_parent' => $parent, 'post_type' => 'page', 'numberposts' => -1, 'post_status' => 'any', 'order' => 'ASC'

);

if($parent){

foreach(get_children($args) as $child){

echo '

'.$child->post_title.'';

}

}

现在我想为特定页面使用不同的方法。

我有4个页面, 其ID为131、119、63和59。

以上述方式, 将在59、63、119、131中订购遗嘱。

我希望他们订购63、59、131、119

我该如何做而不更改其他页面子菜单?

谢谢你帮忙 :)

#1

试试这个

$args = array(

'post_parent' => $parent, 'post_type' => 'page', 'numberposts' => -1, 'post_status' => 'any', 'orderby' => 'post__in', 'post__in' => array(63, 59, 131, 119), );

#2

$args = array(

'post_parent' => $parent, 'post_type' => 'page', 'numberposts' => -1, 'post_status' => 'any', 'post__in' => [63, 59, 131, 119], 'orderby' => 'post__in', );

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值