WordPress function: get the general settings of blog_ bloginfo()、bloginfo()

Function get_ Bloginfo() and bloginfo(), which can obtain information in WordPress user profile and general settings, such as blog title, blog address URL, WordPress version, etc.

get_ Bloginfo() returns a string to call. Bloginfo() has echo property and can be output immediately.

Function usage

<?php $bloginfo = get_ bloginfo( $show, $filter ); ?>

<?php bloginfo( $show ); ?>

Function parameters

$show

(string) (optional) keyword to name the information you want.

Default: name

'name' - returns the blog title set in Settings > general. This data can be downloaded from WP_ Options is retrieved from "blogname" in the table.

'description '- returns the subtitle set in Settings > general. This data can be downloaded from WP_ Options is retrieved from "blogdescription" in the table.

'wpull' - returns the "WordPress address (URL)" set in Settings > general. This data can be downloaded from WP_ Options is retrieved from "siteurl" in the table. Consider using site_ URL () substitution, especially when configuring multiple sites using a subdirectory path instead of a subdomain name (bloginfo will return the URL of the root site instead of the URL of the subsite).

'siteurl '/'url' - displays the site address (URL) set in Settings > general. The data is from WP_ The "home" record retrieved from the options data table. Consider using home_ URL () instead.

'admin_ Email '- displays the "email address" set in Settings > general. The data is from WP_ Options "admin" retrieved from the data table_ Email "record.

'charset' - displays the "page and feed encoding" set in Settings > general. The data is from WP_ The "blog" retrieved from the options data table_ Charset "record. (Note: 3.5.1 + seems to have no such option.)

'version' - displays the version of WordPress you are currently using. The data is in WP includes/ version.php Retrieved $WP_ The value of the version field.

'html_ Type '- displays the content type in the WordPress HTML page (default: "text / HTML"). The data can be downloaded from WP_ The "HTML" retrieved from the options data table_ Type "record. Themes and plug-ins can be created by using pre_ option_ html_ The type filter override the default.

'text_ Direction '- displays the text direction of the WordPress HTML page. Consider using is_ RTL () instead.

'language' - displays the language of WordPress.

'stylesheet_ URL '- displays the CSS file of the currently used theme (usually style.css )Path. Consider using get_ stylesheet_ Uri () instead.

'stylesheet_ Directory '- displays the style sheet path of the currently used theme. Consider using get_ stylesheet_ directory_ Uri () instead.

'template_ url' / 'template_ Directory '- the URL path of the current topic. In the subtopic, get_ bloginfo('template_ URL '), and get_ Template () will return the directory of the parent theme. Consider using get_ template_ directory_ Uri () (for parent topic directory) or get_ stylesheet_ directory_ Uri () (for sub topic directory) instead.

'pingback_ URL '- displays the URL of the notification file XML-RPC( xmlrpc.php )

'atom_ URL '- displays the atom feed URL (/ feed / atom)

'rdf_ URL '- displays the RDF / RSS 1.0 feed URL (/ feed / RFD)

'rss_ URL '- display RSS 0.92 feed URL (/ feed / RSS)

'rss2_ URL '- displays the RSS 2.0 feed URL (/ feed)

'comments_ atom_ URL '- displays the atom feed URL of the comment (/ comments / feed)

'comments_ rss2_ URL '- RSS 2.0 feed URL (/ comments / feed) showing comments

$filter

(string) (optional) keyword specifies how to filter the retrieved data.

Default: raw

'display '- filter the value of $show through the wptexturize() function, and then return the output to the requester.

'raw' - returns the value of $show directly.

Specific examples

Example: get_ bloginfo()

By default, define your blog title to $blog_ The title variable.

<?php $blog_ title = get_ bloginfo(); ?>
  1. Blog title

The following example defines your blog title to $blog_ The output of the title variable is the same as the default usage above.

<?php $blog_ title = get_ bloginfo('name'); ?>
  1. Blog subtitle

Use the following example:

<? PHP echo 'the subtitle of your blog is:' get_ bloginfo ( 'description' ); ?><br />

Back to reality: the subtitle of your blog is: all things WordPress

Example: bloginfo ()

  1. Show blog title

Show blog title in H1 tag

<h1><?php bloginfo('name'); ?></h1>
  1. Show blog titles with links

Show a blog title with a link to the site

<a href="<?php bloginfo('url'); ?>" title="<?php bloginfo('name'); ?>"><?php bloginfo('name'); ?></a>

Display character set

Character set: <?php bloginfo('charset'); ?>
  1. Show blog description

Show subtitles set in Settings > General

<?php bloginfo('description'); ?>

Original article, author: brian, if reprinted, please indicate the source:https://www.nicebrian.com/22.html

Leave a Reply

Your email address will not be published. Required fields are marked *