get_blog_post( int $blog_id, int $post_id )
Get a blog post from any site on the network.
描述
参数
- $blog_id
-
(int)
(Required)
ID of the blog. - $post_id
-
(int)
(Required)
ID of the post you’re looking for.
返回值
(WP_Post|null) WP_Post on success or null on failure
源代码
File: wp-includes/ms-functions.php
function get_blog_post( $blog_id, $post_id ) {
switch_to_blog( $blog_id );
$post = get_post( $post_id );
restore_current_blog();
return $post;
}
更新日志
Version | 描述 |
---|---|
MU 1.0 | Introduced. |
相关函数
Uses
-
wp-includes/post.php:
get_post() -
wp-includes/ms-blogs.php:
switch_to_blog() -
wp-includes/ms-blogs.php:
restore_current_blog()
-
Skip to note content
You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this note
Contributed by
Codex
Example
Get the post with id 6 from site 3:
$post_6 = get_blog_post( 3, 6 ); if ( $post_6 ) { echo $post_6->post_title; }
你可能对这些文章感兴趣:
- wordpress函数get_the_posts_navigation()用法示例
- wordpress函数get_the_title()用法示例
- wordpress函数get_the_terms()用法示例
- wordpress函数get_the_tags()用法示例
- wordpress函数get_the_taxonomies()用法示例
- wordpress函数get_the_permalink()用法示例
- wordpress函数get_the_password_form()用法示例
- wordpress函数get_the_posts_pagination()用法示例
- wordpress函数get_the_modified_date()用法示例
- wordpress函数get_the_modified_time()用法示例
- wordpress函数get_the_modified_author()用法示例
- wordpress函数get_the_guid()用法示例
- wordpress函数get_the_ID()用法示例
- wordpress函数get_the_excerpt()用法示例
如有疑问,请前往问答中心反馈!
反馈