WordPress

WordPress TutorialRemove Version from WordPress and StylesheetsRun WordPress local with XAMPPSecurity in WordPress - EscapingSecurity in WordPress - SanitizationThe Loop (main WordPress loop)Update WordPress ManuallyWordPress Actions and FiltersWordPress add action()WordPress add editor style()WordPress add menu page()WordPress Add ShortcodeWordPress add submenu page()WordPress add theme support()WordPress Add/remove contact info for users with user contactmethods filter hookWordPress Admin Dashboard WidgetsWordPress AJAXWordPress Alternating main loop (pre get posts filter)WordPress Child Theme BasicsWordPress Create a Post ProgrammaticallyWordPress Create Template for Custom Post TypeWordPress Creating a custom templateWordPress Custom exerpts with excerpt length and excerpt moreWordPress Custom Post TypesWordPress Customizer Basics (Add Panel, Section, Setting, Control)WordPress Customizer Hello WorldWordPress DebuggingWordPress Enqueuing scriptsWordPress Enqueuing StylesWordPress Function : wp trim words()WordPress Function: add action()WordPress get bloginfo()WordPress get home path()WordPress get option()WordPress get permalink()WordPress get template part()WordPress get the category()WordPress get the title()WordPress home url()WordPress How Can I integrate Markdown editor with Advance Custom Fields repeater Add-on.WordPress initWordPress Installation and ConfigurationWordPress Making network requests with HTTP APIWordPress Meta BoxWordPress Options APIWordPress Plugin creationWordPress Plugin developmentWordPress Post FormatsWordPress Querying postsWordPress Remove Auto Line Breaks from Content and ExcerptWordPress REST APIWordPress Secure your installationWordPress ShortcodeWordPress Shortcode with attributeWordPress ShortcodesWordPress SidebarsWordPress Site MigrationWordPress TaxonomiesWordPress Template hierarchyWordPress template includeWordPress the $wpdb ObjectWordPress the Admin Bar (aka The Toolbar)WordPress the title()WordPress theme and child-theme developmentWordPress ThemesWordPress wp get current user()WordPress WP Query() LoopWordPress WP-CLIWordPress WP-Cron



WordPress get bloginfo()

From WikiOD

Retrieves information about the current site.

Syntax[edit | edit source]

  • get_bloginfo( $show , $filter )

Parameters[edit | edit source]

Parameter Details
$show (string) The site setting information to retrieve.
$filter (string) The specification on whether to return a filtered value or not.

Remarks[edit | edit source]

$show

Values Description Example
'name' (Default) Site title 'Matt Mullenweg'
'description' Site tagline 'Just another WordPress site'
'wpurl' URL of the WordPress installation. Same as the site_url() function 'http://example.com' , 'http://localhost/wordpress'
'url' URL of the site. Same as the home_url() function 'http://example.com' , 'http://localhost/wordpress'
'admin_email' Email address of the main Administrator 'matt@mullenweg.com'
'charset' Character encoding of the pages and feeds 'UTF-8'
'version' Current version of the WordPress installation '4.5'
'html_type' content-type value of the HTML 'text/html'
'text_direction' Text direction determined by the site’s language 'ltr'
'language' ISO 639-1 based language code 'en-US'
'stylesheet_url' URL of the stylesheet of the activated theme. Value priority: Child theme » Parent theme. 'http://example.com/wp-content/themes/twentysixteen/style.css'
'stylesheet_directory' Resource location of the activated theme. Value priority: Child theme » Parent theme. 'http://example.com/wp-content/themes/twentysixteen'
'template_url' URL directory of the activated theme. Value priority: Parent theme » Child theme. 'http://example.com/wp-content/themes/twentysixteen'
'template_directory' Same as 'template_url'
'pingback_url' Pingback XML-RPC file 'http://example/xmlrpc.php'
'atom_url' Atom feed URL 'http://example/feed/atom/'
'rdf_url' RDF/RSS 1.0 feed URL 'http://example/feed/rdf/'
'rss_url' RSS 0.92 feed URL 'http://example/feed/rss/'
'rss2_url' RSS 2.0 feed URL 'http://example/feed/'
'comments_atom_url' Comments Atom feed URL 'http://example/comments/feed/atom/'
'siteurl' (deprecated) Use ‘url’ instead
'home' (deprecated) Use ‘url’ instead

$filter

Values Description Example
'raw' (Default) No filters will be applied raw data
'display' Filters will be applied to the return value if $show is neither 'url' , 'directory' , 'home' filtered data

Getting the site title[edit | edit source]

<?php echo get_bloginfo( 'name' ); ?>

or

<?php echo get_bloginfo(); ?>

Output

Matt Mullenweg

Based on these sample settings

get_bloginfo()

Getting the active theme URL[edit | edit source]

<?php echo esc_url( get_bloginfo( 'stylesheet_directory' ) ); ?>

Output

http://example.com/wp-content/themes/twentysixteen

Alternatives

Internally, get_bloginfo( 'stylesheet_directory' ) calls get_stylesheet_directory_uri(), so you may want to use that instead:

<?php echo esc_url( get_stylesheet_directory_uri() ); ?>

Many developers prefer to use these dedicated functions because of inconsistent naming conventions between them and get_bloginfo(). For example, get_stylesheet_directory() returns the child theme path; however, as our previous example illustrates, get_bloginfo( 'stylesheet_directory' ) returns the child theme URL. If you use get_stylesheet_directory_uri() instead, there's less chance of confusion over whether you're retrieving a path or a URL.

Getting the site tagline[edit | edit source]

<?php echo get_bloginfo( 'description' ); ?>

Output

Just another WordPress site

Based on these sample settings

get_bloginfo()

Get Email Address of Site Administrator[edit | edit source]

We can use the get_bloginfo function to retrieve the email address of the site administrator.

<?php echo get_bloginfo('admin_email'); ?>

Get site url[edit | edit source]

<?php echo esc_url(get_bloginfo('url')); ?>

or if you needed to link to a sub page

<?php echo esc_url(get_bloginfo('url') . '/some-sub-page');  ?>

This article is an extract of the original Stack Overflow Documentation created by contributors and released under CC BY-SA 3.0. This website is not affiliated with Stack Overflow