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

wordpress函数get_bloginfo()用法示例

get_bloginfo( string $show = '',  string $filter = 'raw' )

Retrieves information about the current site.


描述

Possible values for $show include:

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

  • ‘name’ – Site title (set in Settings > General)
  • ‘描述’ – Site tagline (set in Settings > General)
  • ‘wpurl’ – The WordPress address (URL) (set in Settings > General)
  • ‘url’ – The Site address (URL) (set in Settings > General)
  • ‘admin_email’ – Admin email (set in Settings > General)
  • ‘charset’ – The "Encoding for pages and feeds" (set in Settings > Reading)
  • ‘version’ – The current WordPress version
  • ‘html_type’ – The content-type (default: "text/html"). Themes and plugins can override the default value using the ‘pre_option_html_type’ filter
  • ‘text_direction’ – The text direction determined by the site’s language. is_rtl() should be used instead
  • ‘language’ – Language code for the current site
  • ‘stylesheet_url’ – URL to the stylesheet for the active theme. An active child theme will take precedence over this value
  • ‘stylesheet_directory’ – Directory path for the active theme. An active child theme will take precedence over this value
  • ‘template_url’ / ‘template_directory’ – URL of the active theme’s directory. An active child theme will NOT take precedence over this value
  • ‘pingback_url’ – The pingback XML-RPC file URL (xmlrpc.php)
  • ‘atom_url’ – The Atom feed URL (/feed/atom)
  • ‘rdf_url’ – The RDF/RSS 1.0 feed URL (/feed/rfd)
  • ‘rss_url’ – The RSS 0.92 feed URL (/feed/rss)
  • ‘rss2_url’ – The RSS 2.0 feed URL (/feed)
  • ‘comments_atom_url’ – The comments Atom feed URL (/comments/feed)
  • ‘comments_rss2_url’ – The comments RSS 2.0 feed URL (/comments/feed)

Some $show values are deprecated and will be removed in future versions. These options will trigger the _deprecated_argument() function.

Deprecated arguments include:

  • ‘siteurl’ – Use ‘url’ instead
  • ‘home’ – Use ‘url’ instead

参数

$show

(string)
(Optional)
Site info to retrieve. Default empty (site name).

Default value: ”

$filter

(string)
(Optional)
How to filter what is retrieved.

Default value: ‘raw’


返回值

(string) Mostly string values, might be empty.


源代码

File: wp-includes/general-template.php

function get_bloginfo( $show = '', $filter = 'raw' ) {
	switch( $show ) {
		case 'home' : // DEPRECATED
		case 'siteurl' : // DEPRECATED
			_deprecated_argument( __FUNCTION__, '2.2.0', sprintf(
				/* translators: 1: 'siteurl'/'home' argument, 2: bloginfo() function name, 3: 'url' argument */
				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s option instead.' ),
				'<code>' . $show . '</code>',
				'<code>bloginfo()</code>',
				'<code>url</code>'
			) );
		case 'url' :
			$output = home_url();
			break;
		case 'wpurl' :
			$output = site_url();
			break;
		case '描述':
			$output = get_option('blog 描述');
			break;
		case 'rdf_url':
			$output = get_feed_link('rdf');
			break;
		case 'rss_url':
			$output = get_feed_link('rss');
			break;
		case 'rss2_url':
			$output = get_feed_link('rss2');
			break;
		case 'atom_url':
			$output = get_feed_link('atom');
			break;
		case 'comments_atom_url':
			$output = get_feed_link('comments_atom');
			break;
		case 'comments_rss2_url':
			$output = get_feed_link('comments_rss2');
			break;
		case 'pingback_url':
			$output = site_url( 'xmlrpc.php' );
			break;
		case 'stylesheet_url':
			$output = get_stylesheet_uri();
			break;
		case 'stylesheet_directory':
			$output = get_stylesheet_directory_uri();
			break;
		case 'template_directory':
		case 'template_url':
			$output = get_template_directory_uri();
			break;
		case 'admin_email':
			$output = get_option('admin_email');
			break;
		case 'charset':
			$output = get_option('blog_charset');
			if ('' == $output) $output = 'UTF-8';
			break;
		case 'html_type' :
			$output = get_option('html_type');
			break;
		case 'version':
			global $wp_version;
			$output = $wp_version;
			break;
		case 'language':
			/* translators: Translate this to the correct language tag for your locale,
			 * see https://www.w3.org/International/articles/language-tags/ for reference.
			 * Do not translate into your own language.
			 */
			$output = __( 'html_lang_attribute' );
			if ( 'html_lang_attribute' === $output || preg_match( '/[^a-zA-Z0-9-]/', $output ) ) {
				$output = get_locale();
				$output = str_replace( '_', '-', $output );
			}
			break;
		case 'text_direction':
			_deprecated_argument( __FUNCTION__, '2.2.0', sprintf(
				/* translators: 1: 'text_direction' argument, 2: bloginfo() function name, 3: is_rtl() function name */
				__( 'The %1$s option is deprecated for the family of %2$s functions. Use the %3$s function instead.' ),
				'<code>' . $show . '</code>',
				'<code>bloginfo()</code>',
				'<code>is_rtl()</code>'
			) );
			if ( function_exists( 'is_rtl' ) ) {
				$output = is_rtl() ? 'rtl' : 'ltr';
			} else {
				$output = 'ltr';
			}
			break;
		case 'name':
		default:
			$output = get_option('blogname');
			break;
	}

	$url = true;
	if (strpos($show, 'url') === false &&
		strpos($show, 'directory') === false &&
		strpos($show, 'home') === false)
		$url = false;

	if ( 'display' == $filter ) {
		if ( $url ) {
			/**
			 * Filters the URL returned by get_bloginfo().
			 *
			 * @since 2.0.5
			 *
			 * @param mixed $output The URL returned by bloginfo().
			 * @param mixed $show   Type of information requested.
			 */
			$output = apply_filters( 'bloginfo_url', $output, $show );
		} else {
			/**
			 * Filters the site information returned by get_bloginfo().
			 *
			 * @since 0.71
			 *
			 * @param mixed $output The requested non-URL site information.
			 * @param mixed $show   Type of information requested.
			 */
			$output = apply_filters( 'bloginfo', $output, $show );
		}
	}

	return $output;
}

更新日志

Version 描述
0.71 Introduced.

More Information

Usage


$bloginfo = get_bloginfo( $show, $filter );

相关函数

Uses

  • wp-includes/theme.php:
    get_stylesheet_uri()
  • wp-includes/theme.php:
    get_stylesheet_directory_uri()
  • wp-includes/theme.php:
    get_template_directory_uri()
  • wp-includes/l10n.php:
    __()
  • wp-includes/l10n.php:
    get_locale()
  • wp-includes/general-template.php:
    bloginfo_url
  • wp-includes/general-template.php:
    bloginfo
  • wp-includes/functions.php:
    _deprecated_argument()
  • wp-includes/l10n.php:
    is_rtl()
  • wp-includes/link-template.php:
    home_url()
  • wp-includes/link-template.php:
    site_url()
  • wp-includes/link-template.php:
    get_feed_link()
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/option.php:
    get_option()
  • Show 9 more uses


Used By

  • wp-includes/class-wp-editor.php:
    _WP_Editors::print_tinymce_scripts()
  • wp-includes/class-wp-editor.php:
    _WP_Editors::default_settings()
  • wp-includes/customize/class-wp-customize-nav-menu-item-setting.php:
    WP_Customize_Nav_Menu_Item_Setting::get_original_title()
  • wp-includes/embed.php:
    the_embed_site_title()
  • wp-includes/general-template.php:
    get_custom_logo()
  • wp-includes/embed.php:
    get_post_embed_html()
  • wp-includes/embed.php:
    get_oembed_response_data()
  • wp-includes/theme.php:
    get_header_image_tag()
  • wp-includes/general-template.php:
    wp_get_document_title()
  • wp-includes/general-template.php:
    get_language_attributes()
  • wp-includes/class-wp-customize-nav-menus.php:
    WP_Customize_Nav_Menus::search_available_items_query()
  • wp-includes/class-wp-customize-nav-menus.php:
    WP_Customize_Nav_Menus::customize_register()
  • wp-includes/class-wp-customize-nav-menus.php:
    WP_Customize_Nav_Menus::load_available_items_query()
  • wp-includes/customize/class-wp-customize-media-control.php:
    WP_Customize_Media_Control::to_json()
  • wp-admin/includes/class-wp-press-this.php:
    WP_Press_This::html()
  • wp-admin/includes/class-wp-press-this.php:
    WP_Press_This::fetch_ 源代码 _html()
  • wp-admin/includes/upgrade.php:
    wp_install_maybe_enable_pretty_permalinks()
  • wp-includes/class-wp-customize-panel.php:
    WP_Customize_Panel::json()
  • wp-includes/class-wp-customize-section.php:
    WP_Customize_Section::json()
  • wp-includes/media.php:
    wpview_media_sandbox_styles()
  • wp-login.php:
    login_footer()
  • wp-login.php:
    login_header()
  • wp-admin/includes/class-wp-automatic-updater.php:
    WP_Automatic_Updater::run()
  • wp-admin/includes/class-wp-automatic-updater.php:
    WP_Automatic_Updater::after_core_update()
  • wp-admin/includes/class-wp-automatic-updater.php:
    WP_Automatic_Updater::send_email()
  • wp-admin/includes/class-wp-automatic-updater.php:
    WP_Automatic_Updater::send_debug_email()
  • wp-admin/includes/export.php:
    export_wp()
  • wp-admin/includes/ms.php:
    _access_denied_splash()
  • wp-admin/includes/update.php:
    core_update_footer()
  • wp-admin/includes/update.php:
    update_right_now_message()
  • wp-admin/includes/dashboard.php:
    wp_check_browser_version()
  • wp-admin/includes/plugin-install.php:
    install_plugin_information()
  • wp-admin/includes/class-wp-plugin-install-list-table.php:
    WP_Plugin_Install_List_Table::display_rows()
  • wp-admin/includes/class-wp-plugin-install-list-table.php:
    WP_Plugin_Install_List_Table::prepare_items()
  • wp-admin/includes/post.php:
    _fix_attachment_links()
  • wp-admin/includes/user.php:
    admin_created_user_email()
  • wp-admin/includes/credits.php:
    wp_credits()
  • wp-admin/update-core.php:
    list_core_update()
  • wp-admin/update-core.php:
    core_upgrade_preamble()
  • wp-admin/update-core.php:
    list_plugin_updates()
  • wp-includes/pluggable.php:
    wp_mail()
  • wp-includes/general-template.php:
    register_admin_color_schemes()
  • wp-includes/general-template.php:
    wp_admin_css_uri()
  • wp-includes/general-template.php:
    get_the_generator()
  • wp-includes/general-template.php:
    feed_links()
  • wp-includes/general-template.php:
    feed_links_extra()
  • wp-includes/general-template.php:
    bloginfo()
  • wp-includes/deprecated.php:
    get_index_rel_link()
  • wp-includes/class-wp.php:
    WP::handle_404()
  • wp-includes/class-http.php:
    WP_Http::request()
  • wp-includes/functions.php:
    wp_nonce_ays()
  • wp-includes/functions.php:
    cache_javascript_headers()
  • wp-includes/widgets/class-wp-widget-meta.php:
    WP_Widget_Meta::widget()
  • wp-includes/class-wp-locale.php:
    WP_Locale::init()
  • wp-includes/link-template.php:
    get_pagenum_link()
  • wp-includes/update.php:
    wp_update_plugins()
  • wp-includes/update.php:
    wp_update_themes()
  • wp-includes/admin-bar.php:
    wp_admin_bar_site_menu()
  • wp-includes/feed.php:
    html_type_rss()
  • wp-includes/feed.php:
    get_bloginfo_rss()
  • wp-includes/media.php:
    wp_prepare_attachment_for_js()
  • wp-includes/ms-functions.php:
    filter_SSL()
  • wp-includes/class-wp-xmlrpc-server.php:
    wp_xmlrpc_server::pingback_ping()
  • wp-includes/class-wp-xmlrpc-server.php:
    wp_xmlrpc_server::initialise_blog_option_info()
  • wp-includes/class-wp-customize-widgets.php:
    WP_Customize_Widgets::enqueue_scripts()
  • wp-includes/script-loader.php:
    wp_default_styles()
  • wp-includes/comment.php:
    weblog_ping()
  • wp-includes/script-loader.php:
    wp_default_scripts()
  • wp-includes/comment.php:
    pingback()
  • Show 64 more used by
    Hide more used by


  1. 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

    Default Usage
    The default usage assigns your blog’s title to the variable $blog_title.

    
    <?php $blog_title = get_bloginfo(); ?>
    
  2. Blog Title
    This example assign your blog’s title to the variable $blog_title. This returns the same result as the default usage.

    
    <?php $blog_title = get_bloginfo( 'name' ); ?>
    

    Blog Tagline
    Using this example:

    
    <?php printf( esc_html__( 'Your Blog Tagline is: %s', 'textdomain' ), get_bloginfo ( '描述' ) ); ?><br />
    

    Results in this being displayed on your blog:

    Your Blog Tagline is: All things WordPress

    Network Tagline
    Using this example, you can obtain the name and 描述 for the network home:

    
    <?php
    switch_to_blog(1);
    $site_title = get_bloginfo( 'name' );
    $site_url = network_site_url( '/' );
    $site_ 描述 = get_bloginfo( '描述' );
    restore_current_blog();
    echo 'The Network Home URL is: ' . $site_url;
    echo 'The Network Home Name is: ' . $site_title;
    echo 'The Network Home Tagline is: ' . $site_ 描述;  
    ?>
    

    results in this being displayed on your blog:

    The Network Home URL is: http://example.com/
    The Network Home Name is: Example
    The Network Home Tagline is: The example site

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

热门推荐

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

反馈