_wp_nav_menu_meta_box_object

函数
_wp_nav_menu_meta_box_object ( $data_object = null )
Access
Private
参数
  • (object) $data_object The post type or taxonomy meta-object.
    Required:
    Default: null
返回值
  • (object) The post type or taxonomy object.
定义位置
相关方法
wp_nav_menu_max_depthwp_initial_nav_menu_meta_boxeswp_get_nav_menu_objectwp_nav_menu_taxonomy_meta_boxeswp_nav_menu_post_type_meta_boxes
引入
3.0.0
弃用
-

_wp_nav_menu_meta_box_object: 这个函数返回导航菜单项元框的WP_Nav_Menu_Meta_Box实例。

为一些元框对象类型添加自定义参数。

function _wp_nav_menu_meta_box_object( $data_object = null ) {
	if ( isset( $data_object->name ) ) {

		if ( 'page' === $data_object->name ) {
			$data_object->_default_query = array(
				'orderby'     => 'menu_order title',
				'post_status' => 'publish',
			);

			// Posts should show only published items.
		} elseif ( 'post' === $data_object->name ) {
			$data_object->_default_query = array(
				'post_status' => 'publish',
			);

			// Categories should be in reverse chronological order.
		} elseif ( 'category' === $data_object->name ) {
			$data_object->_default_query = array(
				'orderby' => 'id',
				'order'   => 'DESC',
			);

			// Custom post types should show only published items.
		} else {
			$data_object->_default_query = array(
				'post_status' => 'publish',
			);
		}
	}

	return $data_object;
}

常见问题

FAQs
查看更多 >