WordPress API Description
WordPress Template Tags API Table
目录:
List & Dropdown Functions
General tags
Author tags
Category tags
Template Tags
Post tags
Post Thumbnail tags
一. List & Dropdown Functions
Function: wp_list_authors()
Function: wp_list_categories()
Function: wp_list_pages()
Function: wp_list_bookmarks()
Function: wp_list_comments()
Function: wp_get_archives()
Function: wp_page_menu()
Function: wp_dropdown_pages()
Function: wp_dropdown_categories()
Function: wp_dropdown_users()
Function: wp_dropdown_roles()
Function: wp_dropdown_languages()
二. General tags
API | Description |
---|---|
get_header() | Includes the header.php template file from your current theme's directory. If a name is specified then a specialised header header-{name}.php will be included. |
get_footer() | Includes the footer.php template file from your current theme's directory. if a name is specified then a specialised footer footer-{name}.php will be included. |
get_sidebar() | Includes the sidebar template for a theme or if a name is specified then a specialised sidebar will be included. |
get_template_part() | Makes it easy for a theme to reuse sections of code in a easy to overload way for child themes. |
get_search_form() | This function is primarily used by themes which want to hardcode the search form into the sidebar and also by the search widget in WordPress. |
wp_loginout() | Displays a login link, or if a user is logged in, displays a logout link. An optional, redirect argument can be used to redirect the user upon login or logout. |
wp_logout_url() | This Template Tag returns the URL that allows the user to log out of the site. |
wp_login_url() | This Template Tag returns the URL that allows the user to log in to the site. |
wp_login_form() | Provides a simple login form for use anywhere within WordPress. By default, it echoes the HTML immediately. Pass array('echo' => false) to return the string instead. |
wp_lostpassword_url() | This Template Tag returns the URL that allows the user to retrieve the lost password. |
wp_register() | This tag displays either the "Site Admin" link if the user is logged in or "Register" link if the user is not logged in. |
wp_meta() | Creates the wp_meta action hook, allowing functions to insert content to the sidebar. By default, wp meta() is called immediately after wp_loginout() by sidebar.php and the Meta widget, allowing functions to add new list items to the widget. |
bloginfo() | Displays information about the current site. |
get_bloginfo() | Retrieves information about the current site. |
get_current_blog_id() | Retrieve the current blog id |
wp_title() | Display or retrieve page title for all areas of blog. |
single_post_title() | Displays or returns the title of the post when on a single post page (permalink page). This tag can be useful for displaying post titles outside The Loop. |
post_type_archive_title() | Display or retrieve title for a post type archive. |
single_cat_title() | Display or retrieve page title for category archive. |
single_tag_title() | Displays or returns the tag title for the current archive page |
single_term_title() | Displays or returns the term title for the current page. |
single_month_title() | Displays or returns the month and year title for the current page. |
get_archives_link() | Retrieve archive link content based on predefined or custom code. |
wp_get_archives() | This function displays a date-based archives list. This tag can be used anywhere within a template. |
calendar_week_mod() | Get number of days since the start of the week. |
get_calendar() | Displays the calendar (defaults to current month/year). Days with posts are styled as such. This tag can be used anywhere within a template. |
wp_enqueue_script() | Enqueue a script. |
三. Author tags
API | Description |
---|---|
the_author() | The author of a post can be displayed by using this Template Tag. This tag must be used within The Loop. To return to PHP rather than displaying, use get_the_author() |
get_the_author() | Retrieve the post author's display name. This tag must be used within The Loop. To get the post author's ID, use <?php get_the_author_id(); ?>. |
the_author_link() | This tag displays a link to the Website for the author of a post. The Website field is set in the user's profile (Administration > Profile > Your Profile). The text for the link is the author's Profile Display name publicly as field. This tag must be used within The Loop. |
get_the_author_link() | get_the_author_link() returns the link for use in PHP. To display the link instead, use the_author_link(). |
the_author_meta() | The the_author_meta Template Tag displays a desired meta data field for a user. Only one field is returned at a time, you need to specify which you want. |
the_author_posts() | Displays the total number of posts an author has published. Drafts and private posts aren't counted. This tag must be used within The Loop |
the_author_posts_link() | Displays a link to all posts by an author. The link text is the user's Display name publicly as field |
wp_dropdown_users() | Create dropdown HTML content of users. |
wp_list_authors() | Displays a list of the sites's authors (users), and if the user has authored any posts |
get_author_posts_url() | Gets the URL of the author page for the author with a given ID. |
四. Category tags
API | Description |
---|---|
category_description() | Returns the description of a category defined in the category settings screen for the current category |
single_cat_title() | isplay or retrieve page title for category archive |
the_category() | Displays a link to the category or categories a post belongs to. This tag must be used within The Loop. |
the_category_rss() | Display the post categories in the feed. |
wp_dropdown_categories() | Display or retrieve the HTML dropdown list of categories. |
wp_list_categories() | Display or retrieve the HTML list of categories |
single_tag_title() | Displays or returns the tag title for the current archive page. |
tag_description() | First available with WordPress Version 2.8, this template tag returns the description of a tag. A tag ID can be passed as a parameter, but if no tag ID is passed, the description current queried tag will be returned. |
the_tags() | This template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, nothing is displayed. This tag should be used within The Loop. |
wp_generate_tag_cloud() | Returns an HTML string that makes a tag cloud |
wp_tag_cloud() | The wp_tag_cloud() function displays a list of tags in what is called a 'tag cloud', where the size of each tag is determined by how many times that particular tag has been assigned to posts. |
term_description() | this template tag returns the description of a given term |
single_term_title() | Displays or returns the term title for the current page. |
get_the_term_list() | Returns an HTML string of taxonomy terms associated with a post and given taxonomy. Terms are linked to their respective term listing pages. |
the_terms() | Displays a string of linked terms for a post |
the_taxonomies() | This template tag can be used within The Loop to display Links for taxonomies and belonging Terms for a post without specifying the Post ID |
五. Comment tags
API | Description |
---|---|
cancel_comment_reply_link() | Displays a link which cancels the replying to a previous comment (a nested comment) and resets the comment form back to the default state. |
comment_author() | Displays the comment author name; that is, the one supplied by the commenter. |
comment_author_email() | Displays the comment author's email address, |
comment_author_email_link() | Displays the comment author's email address, as a mailto link |
comment_author_IP() | Displays the comment author's IP address. This tag must be within The Loop, or a comment loop. |
comment_author_link() | Displays the comment author's name linked to his/her URL, if one was provided. |
comment_author_rss() | Display the current comment author in the feed |
comment_author_url() | Displays the comment author's URL (usually their web site), not linked. |
comment_author_url_link() | Displays the comment author's URL (usually their web site), linked |
comment_class() | This function displays comment classes, which will help theme authors perform simpler styling. |
comment_date() | Displays the date a comment was posted. |
comment_excerpt() | Displays an excerpt (maximum of 20 words) of a comment's text. |
comment_form_title() | Displays text based on comment reply status. |
comment_form() | This tag outputs a complete commenting form for use within a template. |
comment_ID() | Displays the numeric ID of the current comment. This tag must be within The Loop, or a comment loop. |
comment_id_fields() | Generates two hidden inputs for the comment form to identify the comment_post_ID and comment_parent for threaded comments. |
comment_reply_link() | Displays a link that lets users post a comment in reply to a specific comment |
comment_text() | Displays the text of a comment. Use get_comment_text() to return a value instead of displaying it. |
comment_text_rss() | Display the current comment content for use in the feeds. |
comment_time() | Displays the time a comment was posted. This tag must be within The Loop, or a comment loop. |
comment_type() | Displays the type of comment (regular comment, Trackback or Pingback) a comment entry is. This tag must be within The Loop, or a comment loop. |
comments_link() | The comments_link template tag displays the URL to the current post's comments. This tag must be within The Loop, or the loop set up for comments. |
comments_number() | Displays the total number of comments, Trackbacks, and Pingbacks for the current post. This tag must be within The Loop. |
comments_popup_link() | Displays a link to the comments popup window if comments_popup_script() is used, otherwise it displays a normal link to comments. This tag must be within The Loop or a comment loop. |
comments_popup_script() | |
get_avatar() | The "get_avatar" filter can be used to alter the avatar image returned by the get_avatar() function. |
next_comments_link() | Display link to next comments pages |
paginate_comments_links() | Create pagination links for the comments on the current post. |
previous_comments_link() | Display the previous comments page link |
wp_list_comments() | Displays all comments for a post or Page based on a variety of parameters including ones set in the administration area |
get_comment_pages_count | Calculate the total number of comment pages |
六. Post tags
API | Description |
---|---|
body_class() | Display the classes for the body element. |
next_image_link() | This creates a link to the next image attached to the current post. Whenever a series of images are linked to the attachment page, it will put a 'next image link' with the images when viewed in the attachment page. |
next_post_link() | Used on single post permalink pages, this template tag displays a link to the next post which exists in chronological order from the current post. |
next_posts_link() | Prints a link to the next set of posts within the current query. If you need the values for use in PHP, use get_next_posts_link(). |
post_class() | WordPress theme authors who want to have finer css control options for their post styling, have the post_class function available. When the post_class function is added to a tag within the loop, for example <div <?php post_class(); ?> >, |
post_password_required() | Whether post requires password and correct password has been provided. |
posts_nav_link() | Displays links for next and previous pages. Useful for providing "paged" navigation of index, category and archive pages. |
previous_image_link() | This creates a link to the previous image attached to the current post. Whenever a series of images are linked to the attachment page, it will put a 'previous image link' with the images when viewed in the attachment page. |
previous_post_link() | Used on single post permalink pages, this template tag displays a link to the previous post which exists in chronological order from the current post. |
previous_posts_link() | Prints a link to the previous set of posts within the current query. |
single_post_title() | Displays or returns the title of the post when on a single post page (permalink page). This tag can be useful for displaying post titles outside The Loop. |
sticky_class() | This function has been deprecated. Use post_class() instead |
the_category() | Displays a link to the category or categories a post belongs to. This tag must be used within The Loop. |
the_category_rss() | Display the post categories in the feed |
the_content() | Display the post content. |
the_content_rss() | This function has been deprecated. Use the_content_feed() instead. |
the_excerpt() | Display the post excerpt. |
the_excerpt_rss() | Display the post excerpt for the feed |
the_ID() | Displays the numeric ID of the current post. This tag must be within The Loop. |
the_meta() | This is a simple built-in function for displaying custom fields for the current post, known as the "post-meta" (stored in the wp_postmeta table). It formats the data into an unordered list (see output below). |
the_tags() | This template tag displays a link to the tag or tags a post belongs to. If no tags are associated with the current entry, nothing is displayed. This tag should be used within The Loop. |
the_title() | Displays or returns the title of the current post. This tag may only be used within The Loop, |
get_the_title() | Retrieve post title. |
the_title_attribute() | Displays or returns the title of the current post. It somewhat duplicates the functionality of the_title(), but provides a “clean” version of the title for use in HTML attributes by stripping HTML tags with strip_tags() and by converting certain characters (including quotes) to their character entity equivalent with esc_attr(); it also uses query-string style parameters. This tag must be within The Loop. |
the_title_rss() | Display the post title in the feed. |
wp_link_pages() | Displays page-links for paginated posts (i.e. includes the nextpage Quicktag one or more times). This works in much the same way as link_pages() (deprecated), the difference being that arguments are given in query string format. This tag must be within The_Loop. |
get_attachment_link() | Returns the URI of the page for an attachment. |
wp_get_attachment_link() | Filters a retrieved attachment page link |
the_attachment_link() | Outputs an HTML hyperlink to an attachment file or page |
the_search_query() | isplays the search query for the current request, if a search was made. |
is_attachment() | This Conditional Tag checks if an attachment is being displayed. An attachment is an image or other file uploaded through the post editor's upload utility. Attachments can be displayed on their own 'page' or template. For more information, see Using Image and File Attachments. |
wp_attachment_is_image() | This function determines if a post's attachment is an image. It returns TRUE if the attachment is an image, FALSE if not. The accepted file extensions/mime types are: .jpg, .jpeg, .gif, .png. |
wp_get_attachment_image() | Get an HTML img element representing an image attachment |
wp_get_attachment_image_src() | A mime icon for files, thumbnail or intermediate size for images |
wp_get_attachment_metadata() | Filters the attachment meta data. |
get_the_date() | The get_the_date template tag retrieves the date the current $post was written. Unlike the_date() this tag will always return the date. Modify output with 'get_the_date' filter. |
single_month_title() | Displays or returns the month and year title for the current page. This tag only works when the m or archive month argument has been passed by WordPress to the current page (this occurs when viewing a monthly archive page). |
the_date() | Displays or returns the date of a post, or a set of posts if published on the same day. |
the_date_xml() | Displays the date of the post in YYYY-MM-DD format (ex: 2004-09-24). This tag must be used within The Loop. |
the_modified_author() | The author who last modified a post can be displayed by using this Template Tag. This tag must be used within The Loop. Note: the_modified_author was first available with Version 2.8. |
the_modified_date() | This tag displays the date (and time) a post was last modified. This tag works just like the_modified_time(), which also displays the time/date a post was last modified. |
the_modified_time() | This tag displays the time (and date) a post was last modified and is similar to the functionality of the_time(), which displays the time (and date) a post was created. |
the_time() | Displays the time of the current post. To return the time of a post, use get_the_time(). This tag must be used within The Loop. |
the_shortlink() | Used on single post permalink pages, this template tag displays a "URL shortening" link for the current post. By default, this will mean the URL has a format of /?p=1234, and will only appear if pretty permalinks are enabled. |
wp_get_shortlink() | Returns the Short Link to a post for use in PHP. It does NOT display the short link. |
七. Post Thumbnail tags
API | Description |
---|---|
has_post_thumbnail() | Check if post has an image attached. |
get_post_thumbnail_id() | If a featured image (formerly known as post thumbnail) is set - Returns the ID of the featured image attached to the post If no such attachment exists, the function returns an empty string If the post does not exist, the function returns false |
the_post_thumbnail() | When a theme adds ‘post-thumbnail’ support, a special ‘post-thumbnail’ |
get_the_post_thumbnail() | Retrieve the post thumbnail |