我正在尝试使用orderby
中的参数get_children
功能如下:
$navigation = get_children(array(
\'post_parent\' => $parent->ID,
\'orderby\' => \'menu_order\'
));
但这对结果没有影响;它仍按默认创建日期排序。有什么想法吗?
我正在尝试使用orderby
中的参数get_children
功能如下:
$navigation = get_children(array(
\'post_parent\' => $parent->ID,
\'orderby\' => \'menu_order\'
));
但这对结果没有影响;它仍按默认创建日期排序。有什么想法吗?
是否确实需要此特定功能?文档(Codex和inline)非常混乱。而且它可能会获取附件之类的东西,这些附件可能与导航无关。。。
试试这个:
get_posts( array(
\'post_type\' => \'page\',
\'post_parent\' => $parent->ID,
\'orderby\' => \'menu_order\'
) );
这个\'orderby\'
参数应与一起使用get_children()
因为get_children()
真的只是一个包装get_posts()
使用不同的默认设置。菜单顺序是指Page Attributes 编辑页面时的元框。。。与自定义菜单的排序顺序不同。
您可以使用$args
在里面get_children
, 但请确保您还指定了要从中检索子项的帖子ID,即使它是您想要的当前页面子项
get_children( array(
\'post_parent\' => $post->ID,
\'orderby\' => \'menu_order\',
\'order\' => \'ASC\'
));
使用WP_Query() 和get_posts()? 在什么情况下使用哪个更好?为什么?