WPMU Functions/get blog details

来自WordPress中文文档
跳转至: 导航搜索

Description

Returns general blog information stored in the wp_blogs table.

Parameters

tt$fields/tt
(integer) (required) A blog ID, a blog name, or an array of fields to query against.
Default: Nonenoinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Notes

This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki检查到模板循环:模板:Parameter/nowiki/pre 检查到模板循环:模板:Parameter

The usage of this template is below: prenowiki检查到模板循环:模板:Parameter/nowiki/pre Let's take a closer look at the parameters..

name
The name of the parameter.
datatype
The datatype that should be given for this parameter when called.
  • string
  • integer
  • boolean
  • mixed
description
A short description of the parameter.
importance
Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
  • required
  • optional
default
If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.

wordpress.org.cn /div /noinclude

tt$getall/tt
(boolean) (optional) Flag indicating if all available data or just a subset of data should be returned (see return values, below).
Default: truenoinclude

div class=template-description style=padding: 0 1.5em; border: 1px solid #eeeeee; background-color: #f9f9f9

Notes

This template is for standardizing how parameters look in the Function Reference and in Template Tags. Here is an example of this template being called: prenowiki检查到模板循环:模板:Parameter/nowiki/pre 检查到模板循环:模板:Parameter

The usage of this template is below: prenowiki检查到模板循环:模板:Parameter/nowiki/pre Let's take a closer look at the parameters..

name
The name of the parameter.
datatype
The datatype that should be given for this parameter when called.
  • string
  • integer
  • boolean
  • mixed
description
A short description of the parameter.
importance
Set this parameter to optional if the parameter is optional. Otherwise, do not declare this parameter—it defaults to required.
  • required
  • optional
default
If this parameter is optional, ttdefault/tt is the value that will be used if the parameter is not declared.

wordpress.org.cn /div /noinclude

Return Values

(object) 
Object containing the following public variables:
blog_id 
(integer) ID of the blog queried.
site_id 
(integer) ID of the site this blog belongs to (as wp_site).
domain 
(string) Domain used to access this blog.
path 
(string) Path used to access this site.
registered 
(string) Date and time this blog was registered.
last_updated 
(string) Date and time this blog was last updated.
public 
(integer) Flag indicating if this blog is public or not.
archived 
(integer) Flag indicating if this blog is archived or not.
mature 
(integer) Flag indicating if this blog has been marked as for a mature audience.
spam 
(integer) Flag indicating if this blog has been marked as spam.
deleted 
(integer) Flag indicating if this blog has been marked as deleted.
lang_id 
(integer) ID of the language this blog is written in.
blogname 
(string) Available only with $getall flag set to true. The name of this blog.
siteurl 
(string) Available only with $getall flag set to true. The URL of the site this blog belongs to.
post_count 
(integer) Available only with $getall flag set to true. The number of posts in this blog.

Usage

%%%<?php get_blog_details( $fields, $getall ); ?>%%%

Examples

%%%<?php

 $blog_details = get_blog_details(1);
 echo 'Blog '.$blog_details->blog_id.' is called '.$blog_details->blogname.'.';

?>%%%

get_blog_details(1); returns an object:

   [blog_id]      => 1
   [site_id]      => 1
   [domain]       => foo-multi-site.com
   [path]         => /site-path/
   [registered]   => 2014-07-31 14:51:09
   [last_updated] => 2014-07-31 15:51:56
   [public]       => 1
   [archived]     => 0
   [mature]       => 0
   [spam]         => 0
   [deleted]      => 0
   [lang_id]      => 0
   [blogname]     => Site Name
   [siteurl]      => http://foo-multi-site.com/this-site
   [post_count]   =>

Notes

To return an object containing all items, use the following syntax: %%%<?php get_blog_details( $blogId ); ?>%%%

Alternatively, to return a specific variable from the above items, you can use the following: %%%<?php get_blog_details( $blogId )->path; ?>%%%

Related

模板:Multisite Blog Tags

includeonlydiv style=clear:both; background-color:#F7F7F7; border:1px solid #CCCCCC; color:#000000; padding:7px; margin:0.5em auto 0.5em auto; vertical-align:middle;See also index of Function Reference and index of Template Tags./div/includeonlynoinclude

Description

This Template is used by Codex:Template Messages.

Usage

pre 检查到模板循环:模板:Message /pre

Result

检查到模板循环:模板:Message

/noinclude