Function Reference/the author meta

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

wordpress.org.cn

Description

The the_author_meta Template Tag displays the desired meta data for a user. If this tag is used within The Loop, the user ID value need not be specified, and the displayed data is that of the current post author. A user ID can be specified if this tag is used outside The Loop.

If the meta field does not exist, nothing is printed.

NOTE: Use get_the_author_meta() if you need to return (not display) the information.

Usage

%%% <?php the_author_meta( $field, $userID ); ?> %%%

Parameters

$field 
(string) Field name for the data item to be displayed. Valid values:
  • user_login
  • user_pass
  • user_nicename
  • user_email
  • user_url
  • user_registered
  • user_activation_key
  • user_status
  • display_name
  • nickname
  • first_name
  • last_name
  • description
  • jabber
  • aim
  • yim
  • user_level
  • user_firstname
  • user_lastname
  • user_description
  • rich_editing
  • comment_shortcuts
  • admin_color
  • plugins_per_page
  • plugins_last_view
  • ID
$userID 
(integer) If the user ID fields is used, then this function display the specific field for this user ID.

Examples

Display the Author's AIM screenname

Displays the value in the author's AIM (AOL Instant Messenger screenname) field.

<p>This author's AIM address is <?php the_author_meta('aim'); ?></p>

Display a User Email Address

Displays the email address for user ID 25.

<p>The email address for user id 25 is <?php the_author_meta('user_email',25); ?></p>

Advanced Uses

A plugin may add an additional field in the registration or manage users, which adds a new value in the wp_usermeta (where wp_ is your data base prefix. For this example we will use a Twitter ID if a plugin set meta_key value to "twitter" and meta_value to "wordpress" then

<p>This author's Twitter name is <?php the_author_meta('twitter'); ?></p>

would return

<p>This author's Twitter name is wordpress</p>

Change Log

Since: 2.8.0

Source File

the_author_meta() is located in onlyincludecodewp-includes/author-template.php/code/onlyinclude

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

Template Description

Link to the source code on http://core.trac.wordpress.org/browser/.

Parameters

  1. filename
  2. (option) path to codetag/code (version) or codetrunk/code. This option is only used for a new function.br /Default: codetrunk/code -- trunk is the latest bleeding edge development version of WordPress.

Usage

Link to the stable version: pre检查到模板循环:模板:Trac/pre

Link to trunk: pre检查到模板循环:模板:Trac/pre

/div

wordpress.org.cn.

Related

the_author, the_author_link, get_the_author_link, the_author_meta, the_author_posts, the_author_posts_link, wp_dropdown_users, wp_list_authors

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