WordPress Template Tags:
In this guide, we will cover some important and useful WordPress theme template tags that you can use in your theme development. These template tags will help you to display content and customize your theme according to your requirements.
Before we dive into the details, let’s quickly go through what a template tag is. A template tag is a code snippet that you can use in your WordPress theme files to display dynamic content.
1: the_title()
This template tag is used to display the post or page title. You can use it in your theme files like this:
2: the_content()
This template tag is used to display the post or page content. You can use it in your theme files like this:
3: the_excerpt()
This template tag is used to display an excerpt of the post or page content. You can use it in your theme files like this:
5: the_author()
This template tag is used to display the author name of the current post or page. You can use it in your theme files like this:
By
6: the_category()
This template tag is used to display the category or categories that a post belongs to. You can use it in your theme files like this:
Filed under:
7: the_time()
This template tag is used to display the date and time of a post or page. You can use it in your theme files like this:
Posted on at
8: the_post_thumbnail()
This template tag is used to display the featured image of a post or page. You can use it in your theme files like this:
9: wp_nav_menu()
This template tag is used to display a custom menu in your theme. You can use it in your theme files like this:
10: get_search_form()
This template tag is used to display the search form in your theme. You can use it in your theme files like this:
11: the_tags()
This template tag is used to display the tags associated with a post. You can use it in your theme files like this:
Tags:
12: comments_template()
This template tag is used to display the comments section in your theme. You can use it in your theme files like this:
13: get_template_part()
This template tag is used to include a template file in your theme. You can use it in your theme files like this:
14: body_class()
This template tag is used to add custom classes to the body element of your theme. You can use it in your theme files like this:
>
15: language_attributes()
This template tag is used to add language attributes to the HTML tag of your theme. You can use it in your theme files like this:
>
16: bloginfo()
This template tag is used to display information about your blog, such as the site title, tagline, or URL. You can check the parameters to fetch the available data here. You can use it in your theme files like this:
Site URL:
17: get_sidebar()
This template tag is used to include the sidebar in your theme. You can use it in your theme files like this:
18: wp_head()
Plugins and WordPress core use this function to insert crucial elements into your document’s header (e.g., scripts, styles, and meta tags). Always put wp_head() just before the closing tag of your theme (usually in header.php):
19: wp_footer()
Plugins and WordPress core use this function to insert crucial elements into your document’s footer section (e.g., scripts, styles, and meta tags). Always put wp_foot() just before the closing tag of your theme (usually in footer.php):
21: get_search_query()
This template tag is used to retrieve the search query string entered by the user. You can use it in your theme files like this:
Search Results for ''
No results found for ''
22: wp_link_pages()
This template tag is used to display pagination links for multi-page posts or pages. You can use it in your theme files like this:
23: get_the_author_meta()
This template tag is used to retrieve the specified metadata of the post author. You can use it in your theme files like this:
24: the_archive_title()
This template tag is used to display the title of the current archive page. You can use it in your theme files like this:
', '' ); ?>
25: the_archive_description()
This template tag is used to display the description of the current archive page. You can use it in your theme files like this:
', '
26: the_terms()
This template tag is used to display the terms of the specified taxonomy for the post. You can use it in your theme files like this:
ID, 'category', 'Posted in ', ', ' ); ?>
That’s it! These are some of the important and useful WordPress theme template tags that you can use in your theme development. By using these template tags, you can display dynamic content and customize your theme according to your requirements. We hope that you found this guide helpful. If you have any questions or suggestions, feel free to leave a comment below. You can find more template tags here.
If you are just starting with WordPress theme development, then this WordPress Developer Roadmap can help you with getting started in the WordPress developer ecosystem.