wp_edit_posts_query
函数
wp_edit_posts_query ( $q = false )
- 参数
-
-
(array|false)
$q
Optional. Array of query variables to use to build the query. Defaults to the `$_GET` superglobal.- Required: 否
- Default: false
-
(array|false)
- 返回值
-
- (array)
- 定义位置
-
-
wp-admin/includes/post.php
, line 1157
-
wp-admin/includes/post.php
- 引入
- 2.5.0
- 弃用
- –
运行查询以获取文章,以便在编辑文章页面列出。
function wp_edit_posts_query( $q = false ) {
if ( false === $q ) {
$q = $_GET;
}
$q['m'] = isset( $q['m'] ) ? (int) $q['m'] : 0;
$q['cat'] = isset( $q['cat'] ) ? (int) $q['cat'] : 0;
$post_stati = get_post_stati();
if ( isset( $q['post_type'] ) && in_array( $q['post_type'], get_post_types(), true ) ) {
$post_type = $q['post_type'];
} else {
$post_type = 'post';
}
$avail_post_stati = get_available_post_statuses( $post_type );
$post_status = '';
$perm = '';
if ( isset( $q['post_status'] ) && in_array( $q['post_status'], $post_stati, true ) ) {
$post_status = $q['post_status'];
$perm = 'readable';
}
$orderby = '';
if ( isset( $q['orderby'] ) ) {
$orderby = $q['orderby'];
} elseif ( isset( $q['post_status'] ) && in_array( $q['post_status'], array( 'pending', 'draft' ), true ) ) {
$orderby = 'modified';
}
$order = '';
if ( isset( $q['order'] ) ) {
$order = $q['order'];
} elseif ( isset( $q['post_status'] ) && 'pending' === $q['post_status'] ) {
$order = 'ASC';
}
$per_page = "edit_{$post_type}_per_page";
$posts_per_page = (int) get_user_option( $per_page );
if ( empty( $posts_per_page ) || $posts_per_page parent';
}
if ( ! empty( $q['show_sticky'] ) ) {
$query['post__in'] = (array) get_option( 'sticky_posts' );
}
wp( $query );
return $avail_post_stati;
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。