^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_others_unpublished_posts()用法示例

Warning: This function has been deprecated. Use get_posts() instead.

get_others_unpublished_posts( int $user_id,  string $type = 'any' )

Retrieves editable posts from other users.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


描述


参数

$user_id

(int)
(Required)
User ID to not retrieve posts from.

$type

(string)
(Optional)
Post type to retrieve. Accepts ‘draft’, ‘pending’ or ‘any’ (all).

Default value: ‘any’


返回值

(array) List of posts from others.


源代码

File: wp-admin/includes/deprecated.php

function get_others_unpublished_posts( $user_id, $type = 'any' ) {
	_deprecated_function( __FUNCTION__, '3.1.0' );

	global $wpdb;

	$editable = get_editable_user_ids( $user_id );

	if ( in_array($type, array('draft', 'pending')) )
		$type_sql = " post_status = '$type' ";
	else
		$type_sql = " ( post_status = 'draft' OR post_status = 'pending' ) ";

	$dir = ( 'pending' == $type ) ? 'ASC' : 'DESC';

	if ( !$editable ) {
		$other_unpubs = '';
	} else {
		$editable = join(',', $editable);
		$other_unpubs = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_title, post_author FROM $wpdb->posts WHERE post_type = 'post' AND $type_sql AND post_author IN ($editable) AND post_author != %d ORDER BY post_modified $dir", $user_id) );
	}

	return apply_filters('get_others_drafts', $other_unpubs);
}

更新日志

Version 描述
3.1.0 Use get_posts()
2.3.0 Introduced.

相关函数

Uses

  • wp-admin/includes/deprecated.php:
    get_editable_user_ids()
  • wp-includes/functions.php:
    _deprecated_function()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/wp-db.php:
    wpdb::get_results()
  • wp-includes/wp-db.php:
    wpdb::prepare()

Used By

  • wp-admin/includes/deprecated.php:
    get_others_drafts()
  • wp-admin/includes/deprecated.php:
    get_others_pending()

让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈