What are the template tags in WordPress ?
Last Updated :
06 Jul, 2022
WordPress is a free and open-source content management system written in PHP language that allows you to contribute to your project, and host websites all over the world at zero cost. WordPress provides different tags and templates to the user to make their project unique and outstanding.
Template tags in WordPress are nothing but a simple PHP function that is used to present data and customize their blog.
Syntax: The template tag is a PHP function. so it must contain <? and ?> brace within its tag . and must end with a semicolon.
<?
php_tag template_tag;
?>
Use:
<?
PHP bloginfo();
?>
The blog info template tag displays the information of the current blog.
Properties:
- Useful to print dynamic content
- PHP function so it’s secure
- Can handle multiple themes and files
- Divide code into smaller part
- Easy to understand.
- Useful to fetch data from the database.
- It can call another theme file within the database.
- Can display data by passing argument.
Template Tags: Template tags files are defined in the wp-includes directory.
Extension: " -template.php"
There are a total of 9 template tags in the wp-includes directory: The following is a list of template tag files that can be used in WordPress.
- wp-includes/general-template.php
- wp-includes/author-template.php
- wp-includes/bookmark-template.php
- wp-includes/category-template.php
- wp-includes/comment-template.php
- wp-includes/link-template.php
- wp-includes/post-template.php
- wp-includes/post-thumbnail-template.php
- wp-includes/nav-menu-template.php
Template Tag List: It contains a total of 9 template tags and these are the following:
- General tags
- Author tags
- Bookmark tags
- Category tags
- Comment tags
- Link tags
- Post tags
- Post Thumbnail tags
- Navigation Menu tags
1. General tag: These are defined in the “wp-includes/general-template.php” directory. This General tag contains a total of 29 template tags. These are the following:
Template tag | Description |
get_header() | Get header template of current blog |
get_bloginfo() | Get information about the current blog site. |
get_footer() | Get footer template of current blog. |
get_sidebar() | Get sidebar template of current blog. |
get_search_form() | Display search form on screen. |
wp_loginout() | Display the Log In and log out form . |
wp_logout_url() | Get logout URL of current blog |
wp_login_form() | Display login form . |
wp_lostpassword_url() | Return password with URL link |
wp_title() | Display page title in all page of blog. |
bloginfo() | Displays information about the current blog site |
2. Author tag: These are the different author tags defined in “wp-includes/author-template.php”. Some of the following:
Template Tag | Description |
get_the_author() | Get the author name of the current blog |
the_author_meta() | Displays a meta data of user. |
the_author() | Display author of the current blog. |
the_author_link() | Display author’s data link. |
get_the_author_link() | Display Author data URL link. |
the_author_posts() | Display the all post count of author |
the_author_posts_link() | Displays link to the author page. |
3. Bookmark tags: These are the only 4 template tags of Bookmark tags that are defined in “wp-includes/bookmark-template.php”.
Template Tag | Description |
wp_list_bookmarks() | Display all of the bookmarks page |
get_bookmark() | fetch Bookmark data |
get_bookmark_field() | display single bookmark data |
get_bookmarks() . | Display the list of bookmarks pages |
4. Category tags:
Template Tag | Description |
wp_list_categories() | Displays the HTML list of categories |
tag_description() | Display tag description |
the_tags() | Displays the tags of post |
wp_generate_tag_cloud() | Generates a tag cloud from provided data |
single_term_title() | Display page title |
category_description() | Display category description |
the_category_rss() | Display the post categories in the feed |
the_category() | Displays category list for a post. |
wp_dropdown_categories() | Displays the HTML dropdown list of categories |
term_description() | Display term description. |
wp_tag_cloud() | Displays a tag cloud. |
5. Comment tags: These are the different comment tag template tags defined in “wp-includes/comment-template.php”. Some of these are the following
Template Tag | Description |
cancel_comment_reply_link() | Displays HTML data for canceled comment reply by admin. |
comment_author_email_link() | Displays the HTML data of email link of author’s current comment |
comment_author_rss() | Display the current comment of author . |
comment_author_link() | Displays the HTML link to the URL of the author's comment |
comment_author_IP() | Displays the IP address of author comment. |
6. Link tags: These are the different template tags defined in “wp-includes/link-template.php”.
Template Tag | Description |
get_permalink() | Get permalink for the current post |
get_page_link() | Display the permalink of post . |
get_admin_url() | Display URL of admin. |
get_home_url() | Display Home Page URL |
get_admin_url() | Display URL of admin page . |
the_permalink() | Displays the permalink for the current post |
7. Post tags: These are the different template tags defined in “wp-includes/post-template.php”
Template Tag | Description |
next_image_link() | Displays image link of next post . |
post_class() | Displays the class of post. |
next_posts_link() | Displays the next posts link |
body_class() | Displays the class name of body . |
8. Post Thumbnail tags: These are only 4 template tags that are defined in “wp-includes/post-thumbnail-template.php”.
Template Tag | Description |
get_post_thumbnail_id() | get thumbnail ID |
get_the_post_thumbnail() | Get the post thumbnail |
the_post_thumbnail() | Display the thumbnail |
has_post_thumbnail() | check whether a post has an thumbnail or not |
9. Navigation Menu tags: These are the only 2 template tags defined in “wp-includes/nav-menu-template.php”.
Template Tag | Description |
walk_nav_menu_tree() | display the HTML data list for navigation of menu items |
wp_nav_menu() | Displays a navigation menu of current blog |
Similar Reads
What are templates on WordPress ?
WordPress, one of the most popular content management systems (CMS) in the world, powers millions of websites. One of the key features that make WordPress so versatile and user-friendly is its use of templates. But what exactly are templates in WordPress, and how can they enhance your website? In th
3 min read
What is a Sidebar in WordPress ?
When you visit a website, have you ever noticed the sections on the side of the main content that often contain additional information, links, or advertisements? In WordPress, these sections are called sidebars. Let's dive into understanding what a sidebar in WordPress is, how it works, and how you
4 min read
WordPress Theme Management
WordPress theme management is a n important aspect of maintaining a professional and visually attractive website. Themes control the layout, design, and overall appearance of your site, making it essential to choose and manage them effectively. This article will walk you through the basics of WordPr
4 min read
A Beginner's Guide to the WordPress Text Editor
WordPress generally uses Content Management Systems (CMS) for creating blogs and websites. It is also known for its simplicity, and dynamic features. Whether you are making a blog, creating a business website, or creating an online portfolio. WordPress provides a user-friendly platform that helps to
15 min read
How to use Categories & Tags in WordPress?
Categories and tags are essential tools for organizing content on your WordPress site. They help improve user experience by making it easier for visitors to find related content and enhance SEO by structuring your site more efficiently. This step-by-step guide will show you how to use categories and
3 min read
How to Add Meta Tags in WordPress?
The process of adding meta tags in WordPress can be accomplished through various methods. By using SEO plugin like Yoast SEO or any other all-in-one SEO pack makes it easy to add meta tags without editing any code. In this article, we explains about adding meta tags in WordPress with different appro
3 min read
What is WordPress?
WordPress is a popular content management system (CMS) that powers over 40% of all websites on the internet. It's an open-source platform that allows users to create, manage, and modify their websites without needing extensive coding knowledge. Whether you're a blogger, business owner, or developer,
7 min read
How to Create a Child Theme in WordPress?
Creating a child theme in WordPress is an essential skill for anyone looking to customize their website without losing changes during theme updates. A child theme allows you to modify the appearance and functionality of a parent theme while keeping your customizations separate and safe. This method
5 min read
WordPress Themes And Plugins
In this article, we will study what are themes and plugins in WordPress and some of the commonly used themes and plugins. Before moving ahead in WordPress themes and plugins, we should know about what is WordPress! WordPress is a free and open-source Content Management System(CMS) framework. It is t
4 min read
What is Widgets in WordPress ?
Welcome to the world of WordPress Widgets! These powerful tools offer a world of possibilities for customizing your website, making it more functional, interactive, and user-friendly. Whether youâre a seasoned WordPress veteran or a beginner just starting, understanding widgets can significantly enh
8 min read