Template Tags in Wordperss
To display Loop content in your WordPress theme used a PHP function and this is called template tags. To display specific pieces of data about your website and content these tags are used. This permits you to customize or change how and where your content is displayed on your website. Let’s suppose, function is the the_title() template tag and is used to displays the title of your post or page inside the Loop. When you use template tags its major benefit is that you don’t need to know PHP code to use them.
There are many different template tags are available in WordPress. Some template tags must be inside the Loop, some other tags can be used anywhere in your theme template files. Remember that, the template tags refer to the WordPress functions used to extract post data for display; the template files are the theme elements that control how content for a particular content type is displayed in the site. You can see updated list of template tags available in WordPress, now visit this address http://codex.wordpress.org/Template_Tags and you can see the templates.
Commonly Used Template Tags There is no shortage of template tags, but commonly you will use only a handful of tags in your Loops. There are the most commonly used template tags available in the Loop which are following and these template tags will return and display the post data listed.
➤ the_permalink() — This is use for displays the URL of your post.
➤ the_title() — This is use for to displays the title of the post.
➤ the_ID() — This is use for to displays the unique ID of your post.
➤ the_content() — This is use for to displays the full content of your post.
➤ the_excerpt() — This is use for to displays the excerpt of your post. While the Excerpt field is filled out on the Post edit screen, that will be used. While it not, then WordPress will auto-generate a short excerpt from your post content.
➤ the_time() — This is use for to displays the date/time your post was published.
➤ the_author() — This is use for to displays the author of the post.
➤ the_tags() — This is use for to displays the tags attached to the post.
➤ the_category() — This is use for to displays the categories assigned to the post.
➤ edit_post_link() — This is use for to displays an edit link that is shown only if you are logged in and
allowed to edit the post.
➤ comments_popup_link() — This is use for to displays a link to the comments form of your post.
How the template tags work, in the method just put any template tag inside the Loop and view the results of tag.
Now see the following example views the values of a couple different template tags:
if ( have_posts() ) :
while ( have_posts() ) :
<a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a>
That you have seen that, your post titles are displayed with links to the permalink for each post and the content of the post is displayed directly below the post title. Tag Parameters Every tag has its different functionality and most of the template tags have parameters that can be added to modify the value returned.
For example, this template tag the_content() template tag has two parameters. The first parameter allows you to set the more link text like that:
<?php the_content( ‘Read more’, false ); ?>
Then your post content will be displayed as normal show in the post, after the adding this parameter <!–more–> tag is found in your post, The WordPress will automatically add the text Read more, it has the link to the entire blog post. The second parameter determines whether to display the teaser paragraph again when viewing the full post. False value is the default so the teaser will be displayed in both places.
WordPress more tag tag allows you to display a defined teaser from the full post on your website. Let’s suppose, on your home page you could display the first paragraph of a post, full blog post only show when a visitor clicks the link to view the full post. For accomplish this, put <!–more–> in your content in HTML view where you want to break to happen. There is a button to insert a More tag into the visual editor.
There is another option that you can also send multiple parameters to any template tag that supports it.
For example, another template tag the_title() in this tag three parameters can passed: $before, $after, and $echo. In this tag the following code sets $after and $before parameters to wrap the post title with h1 tags:
<?php the_title( ‘<h1>’, ‘</h1>’ ); ?>
In the WordPress source code you can also view the actual function. The post template functions are located in wp-includes/post-template.php. For a quick search for function the_title() will lead you to the exact function for the the_title() tag. The Codex for a detailed description you can also use of the template tag which you are working with, so in this case http://codex.wordpress.org/Template_Tags/the_title visit this title.