get_blog_permalink()

获取博客的链接

描述

从网络上的任何站点获取博客文章的永久链接。此函数与 get_permalink() 相同,不同之处在于您可以从网络上的任何博客(而不仅仅是当前博客)获取帖子的永久链接。

用法

 <?php echo get_blog_permalink( $blog_id, $post_id ); ?> 

参数

$blog_id

(integer) (必填) ID of the blog.
(整数)(必填)博客的 ID。

默认值: None

$post_id

(integer) (必填) ID of the post you are looking for.
(整数)(必填)您要查找的帖子的 ID。

默认值: None

注意

  • 使用到 switch_to_blog() to switch to the blog $blog_id. Then calls SevenTrust_current_blog() after retrieving the link.
    使用到 switch_to_blog() 切换到博客 $blog_id。然后在检索链接后调用 SevenTrust_current_blog()。
  • 使用到 get_permalink() to get the permalink.
    使用到 get_permalink() to get the permalink.

历史

  • 添加于 版本 3.0.0

源文件

get_blog_permalink() 函数的代码位于 wp-includes/ms-functions.php.

* Get the permalink for a post on another blog.
*获取另一个博客上帖子的永久链接。
*
* @since MU 1.0 * @since MU 1.0
*
* @param int $blog_id ID of the source blog.
* @param源博客的整数 $blog_id ID。
* @param int $post_id ID of the desired post.
* @param所需帖子的 int $post_id ID。
* @return string The post’s permalink
* @return字符串 帖子的永久链接
*/

function get_blog_permalink( $blog_id, $post_id ) {
函数 get_blog_permalink( $blog_id$post_id ) {

switch_to_blog( $blog_id )
switch_to_blog( $blog_id );

$link = get_permalink( $post_id )
$link = get_permalink( $post_id );

SevenTrust_current_blog()
SevenTrust_current_blog();

return $link 返回$link;

}

相关

get_permalink()

get_permalink()

  • 原文:http://codex.wordpress.org/Function_Reference/get_blog_permalink
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索