向一些元框对象类型添加自定义参数。
原型
_wp_nav_menu_meta_box_object( object $object = null )
参数
$object
(object)
(Optional)
帖子类型或分类法元对象。
返回值
(object)
分类对象的帖子类型。
源文件
路径:wp-admin/includes/nav-menu.php
<?php
...
function _wp_nav_menu_meta_box_object( $object = null ) {
if ( isset( $object->name ) ) {
if ( 'page' == $object->name ) {
$object->_default_query = array(
'orderby' => 'menu_order title',
'post_status' => 'publish',
);
// Posts should show only published items.
} elseif ( 'post' == $object->name ) {
$object->_default_query = array(
'post_status' => 'publish',
);
// Categories should be in reverse chronological order.
} elseif ( 'category' == $object->name ) {
$object->_default_query = array(
'orderby' => 'id',
'order' => 'DESC',
);
// Custom post types should show only published items.
} else {
$object->_default_query = array(
'post_status' => 'publish',
);
}
}
return $object;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/_wp_nav_menu_meta_box_object/