Welcome to the series finale of "The Tuts+ Guide to Template Tags"! It's been a long but great journey, as I said it would be in the first part. And in this last post, we're going to review what we've learned and conclude the series.
First Part
In the first part of the series, we introduced the concept of "template tags" in WordPress: We saw:
- What template tags are
- Where they are
- How are the functions made
- How to use the functions
As I stated a couple of times, template tags are one of the most important and one of the easiest WordPress concepts to learn about. It's only a matter of memorizing the functions and their parameters, just as we need to memorize many PHP functions while learning PHP.
Middle Parts
In the middle parts of the series, we reviewed almost 200 template tags, which are documented in the Codex. Of course, there are many more (maybe twice as more) template tags out there in the core of WordPress, and it would be another journey to review them.
I split the template tags into categorized "batches" to make it easier to learn the template tags in each part. In the first batch, we reviewed template tags about "post data":
- We got and displayed the post content with
get_the_content()
andthe_content()
. - We got and displayed the post content for feeds with
get_the_content_feed()
andthe_content_feed()
. - We got and displayed the excerpt of the post with
get_the_excerpt()
andthe_excerpt()
. - We displayed the excerpt of the post for feeds with
the_excerpt_rss()
. - We got and displayed the post title with
get_the_title()
andthe_title()
. - We got and displayed the "escaped" post title with
the_title_attribute()
. - We displayed the post title for feeds with
the_title_rss()
. - We got and displayed the date of the post with
get_the_date()
andthe_date()
. - We got and displayed the date of the post in ISO 8601 format with
the_date_xml()
. - We got and displayed the time of the post with
get_the_time()
andthe_time()
. - We got and displayed the author's name with
get_the_author()
andthe_author()
. - We displayed all the meta data of the post with
the_meta()
. - We got and displayed the modification date of the post with
get_the_modified_date()
andthe_modified_date()
. - We got and displayed the modification time of the post with
get_the_modified_time()
andthe_modified_time()
. - We got and displayed the author who edited the current post with
get_the_modified_author()
andthe_modified_author()
. - We got and displayed a list of pages of paginated posts with
wp_link_pages()
.
In the second batch, we reviewed template tags about taxonomies and terms:
- We retrieved the description of a category with
category_description()
. - We retrieved the description of a tag with
tag_description()
. - We retrieved the description of a term with
term_description()
. - We got and displayed a page title for category archives with
single_cat_title()
. - We got and displayed a page title for tag archives with
single_tag_title()
. - We got and displayed a page title for term archives with
single_term_title()
. - We got and displayed the categories of the post with
get_the_category_list()
andthe_category()
. - We got and displayed the categories of the post for feeds with
get_the_category_rss()
andthe_category_rss()
. - We got and displayed the tags of a post with
get_the_tag_list()
andthe_tags()
. - We got and displayed the terms of a post with
get_the_term_list()
andthe_terms()
. - We displayed the taxonomies of a post with
the_taxonomies()
. - We got and displayed the "edit tag" link with
get_edit_tag_link()
andedit_tag_link()
. - We got and displayed a list of categories with
wp_list_categories()
. - We got and displayed an HTML dropdown of categories with
wp_dropdown_categories()
. - We got and displayed the tag cloud with
wp_tag_cloud()
. - We retrieved a custom generated tag cloud with
wp_generate_tag_cloud()
.
In the third batch, we reviewed template tags about comments:
- We got and displayed the comment author's name with
get_comment_author()
andcomment_author()
. - We got and displayed the comment author's name for feeds with
get_comment_author_rss()
andcomment_author_rss()
. - We got and displayed the comment author's email address with
get_comment_author_email()
andcomment_author_email()
. - We got and displayed a link of the comment author's email address with
get_comment_author_email_link()
andcomment_author_email_link()
. - We got and displayed the URL of the commenter with
get_comment_author_url()
andcomment_author_url()
. - We got and displayed the link of the commenter (with author name as anchor text) with
get_comment_author_link()
andcomment_author_link()
. - We got and displayed the link of the commenter (with custom text) with
get_comment_author_url_link()
andcomment_author_url_link()
. - We got and displayed the IP address of the commenter with
get_comment_author_ip()
andcomment_author_ip()
. - We got and displayed the content of the comment with
get_comment_text()
andcomment_text()
. - We displayed the content of the comment for feeds with
comment_text_rss()
. - We got and displayed an excerpt of the comment with
get_comment_excerpt()
andcomment_excerpt()
. - We got and displayed the date of the comment with
get_comment_date()
andcomment_date()
. - We got and displayed the time of the comment with
get_comment_time()
andcomment_time()
. - We got and displayed the ID of the comment with
get_comment_id()
andcomment_id()
. - We displayed the type of the comment with
comment_type()
. - We retrieved the avatar of a user with
get_avatar()
.
In the fourth batch, we reviewed template tags about comments again, as there are a lot of comments-related template tags:
- We got and displayed a link to the "comments" section with
get_comments_link()
andcomments_link()
. - We got and displayed the list of comments with
wp_list_comments()
. - We got and displayed the number of comments with
get_comments_number()
andcomments_number()
. - We got and displayed automatic classes for each comment with
get_comment_class()
andcomment_class()
. - We displayed the comment form with
comment_form()
. - We displayed a title for the comment form with
comment_form_title()
. - We got and displayed the "reply to comment" link with
get_comment_reply_link()
andcomment_reply_link()
. - We got and displayed the hidden fields of the "reply to comment" form with
get_comment_id_fields()
andcomment_id_fields()
. - We got and displayed the "cancel reply" link with
get_cancel_comment_reply_link()
andcancel_comment_reply_link()
. - We got and displayed the link for "next comments" with
get_next_comments_link()
andnext_comments_link()
. - We got and displayed the link for "previous comments" with
get_previous_comments_link()
andprevious_comments_link()
. - We retrieved pagination links for the comments with
paginate_comments_links()
. - We got and displayed the "edit comment" link with
get_edit_comment_link()
andedit_comment_link()
. - We got and displayed the "comments feed" link with
get_post_comments_feed_link()
andpost_comments_feed_link()
. - We displayed a link of the "comments" popup with
comments_popup_link()
. - We displayed the "comments" popup script with
comments_popup_script()
.
In the fifth batch, we reviewed template tags about posts, pages and template parts:
- We got and displayed automatic classes for each post with
get_post_class()
andpost_class()
. - We got and displayed the permanent link of current post with
get_permalink()
andthe_permalink()
. - We got and displayed the post ID with
get_the_id()
andthe_id()
. - We got and displayed a page title for the post with
single_post_title()
. - We got and displayed the link of the next post with
get_next_post_link()
andnext_post_link()
. - We got and displayed the link of the previous post with
get_previous_post_link()
andprevious_post_link()
. - We retrieved the permalink of the page with
get_page_link()
. - We got and displayed the permalink of a post with
get_post_permalink()
andpost_permalink()
. - We got and displayed the shortlink of the post with
wp_get_shortlink()
andthe_shortlink()
. - We got and displayed the "edit post" link with
get_edit_post_link()
andedit_post_link()
. - We retrieved the "delete post" link with
get_delete_post_link()
. - We displayed a permalink "anchor" for the current post with
permalink_anchor()
. - We made WordPress load the header template with
get_header()
. - We made WordPress load the footer template with
get_footer()
. - We made WordPress load the sidebar template with
get_sidebar()
. - We made WordPress load a template file with
get_template_part()
.
In the sixth batch, we reviewed template tags about authors and attachments:
- We retrieved the URL of the author's post archives with
get_author_posts_url()
. - We displayed a link to the author's post archives with
the_author_posts_link()
. - We got and displayed the author's website link with
get_the_author_link()
andthe_author_link()
. - We got and displayed the author's meta data with
get_the_author_meta()
andthe_author_meta()
. - We got and displayed the post count of the author with
get_the_author_posts()
andthe_author_posts()
. - We got and displayed the list of authors with
wp_list_authors()
. - We got and displayed an HTML dropdown of users with
wp_dropdown_users()
. - We got and displayed the featured image of the post with
get_the_post_thumbnail()
andthe_post_thumbnail()
. - We retrieved the ID of the post's featured image with
get_post_thumbnail_id()
. - We got and displayed the permalink of an attachment page with
wp_get_attachment_link()
andthe_attachment_link()
. - We retrieved the attachment image with
wp_get_attachment_image()
. - We retrieved the attachment image URL with
wp_get_attachment_image_src()
. - We retrieved the attachment image meta data with
wp_get_attachment_metadata()
. - We retrieved the next image of the same post with
next_image_link()
. - We retrieved the previous image of the same post with
previous_image_link()
.
In the seventh batch, we reviewed template tags about archives, search, login, logout, and registration:
- We retrieved the archive link with
get_archives_link()
. - We got and displayed the archive links with
wp_get_archives()
. - We got and displayed title for a post type archive with
post_type_archive_title()
. - We got and displayed a page title for monthly archives with
single_month_title()
. - We got and displayed the link for the "next posts" page with
get_next_posts_link()
andnext_posts_link()
. - We got and displayed the link for the "previous posts" page with
get_previous_posts_link()
andprevious_posts_link()
. - We got and displayed links for the "next & previous posts" pages with
get_posts_nav_link()
andposts_nav_link()
. - We got and displayed the search form with
get_search_form()
. - We got and displayed the current search query with
get_search_query()
andthe_search_query()
. - We retrieved a permalink for a search query with
get_search_link()
. - We got and displayed a "register" or "dashboard" link with
wp_register()
. - We got and displayed the "log in" form with
wp_login_form()
. - We got and displayed the "log in/out" link with
wp_loginout()
. - We retrieved the "log in" URL with
wp_login_url()
. - We retrieved the "log out" URL with
wp_logout_url()
. - We retrieved the "lost password" URL with
wp_lostpassword_url()
.
And in the last batch, we reviewed template tags about bookmarks and other, "miscellaneous" template tags:
- We retrieved a list of all bookmarks with
get_bookmarks()
. - We got and displayed the list of bookmarks with
wp_list_bookmarks()
. - We retrieved bookmark data with
get_bookmark()
. - We retrieved a single bookmark field's data with
get_bookmark_field()
. - We got and displayed the "edit bookmark" link with
get_edit_bookmark_link()
andedit_bookmark_link()
. - We got and displayed your site's information with
get_bloginfo()
andbloginfo()
. - We got and displayed automatic
<body>
classes withget_body_class()
andbody_class()
. - We got and displayed a navigation menu with
wp_nav_menu()
. - We got and displayed page titles with
wp_title()
. - We got and displayed the home URL with
get_home_url()
andhome_url()
. - We got and displayed the site URL with
get_site_url()
andsite_url()
. - We retrieved the current site's ID with
get_current_blog_id()
. - We got and displayed the URL of the admin panel with
get_admin_url()
andadmin_url()
. - We got and displayed the permalink of a feed type with
get_feed_link()
andthe_feed_link()
. - We made the string end with or without a trailing slash with
user_trailingslashit()
. - We retrieved number of days since the start of the week with
calendar_week_mod()
. - We got and displayed the calendar with
get_calendar()
.
Finale
And here we are, at the end of the series. I hope you enjoyed the articles as much as I enjoyed writing them. If you have any questions, corrections or additions related to the series or the concept of "template tags" in WordPress, feel free to shoot a comment in the Comments section below.
And if you liked this series, don't forget to share the posts with your friends. Goodbye!
by Barış Ünver via Tuts+ Code