setup_postdata

函数


setup_postdata ( $post )
参数
  • (WP_Post|object|int)
    $post
    WP_Post instance or Post ID/object.
    Required:
返回值
  • (bool) True when finished.
定义位置
  • wp-includes/query.php
    , line 1226
引入
1.5.0
弃用

设置全局文章数据。

function setup_postdata( $post ) {
	global $wp_query;

	if ( ! empty( $wp_query ) && $wp_query instanceof WP_Query ) {
		return $wp_query->setup_postdata( $post );
	}

	return false;
}