3 Mar, 2010  |  Written by  |  under WordPress

When I started using WordPress I remember that I couldn’t know how to add a new posts or installing plugin and themes etc.

Over the time I improved my skills by my self experiences and reading a lot of articles about WordPress. Viagra o levitra
But it’s not a big deal you know, the problem is that when I was trying to install some plugins they we’re saying that I must add a piece of code inside Worpress templates and to be specific they we’re saying “Add this code inside the loop” “Add this code after the loop!” and I was saying to my self “What the hell?”.

I had some troubles long time ago and I’m sure there are a lot of people have troubles to add template tags inside the WordPress loop or some troubles in installing plugins that required to add template tags in the loop.

So let’s begin…

What is The Loop?


For example, let’s open the Wordpres classic theme home page.

WordPress Classic theme home page screenshot:

Classic theme home page screenshot


All the content that you see in the home page of WordPress Classic theme is displayed by adding template tags codes inside the loop in the Classic Plavix Online theme index.php file.

So the loop is to displays the content that you see on the homepage, the loop can be used also in single posts, archives, search results and many more.

All what you see in the screenshot above can be displayed also in your post webpage (single post) for example the “retweet” button, you can display it by adding the “retweet” template tag code inside the loop in single.php file (single post page).

How to use the loop? How to add template tags codes in the loop? Where the loop starts and ends Vardenafil levitra ?

Buy asthma drugs #000000;”>
First, I recommend you to use Notepad++ to avoid any errors when you edit your theme files, you can also edit your theme files directly from WordPress admin area.
Open your WordPress theme index.php file and follow the instructions below.
Buy Viagra Professional Online Pharmacy No Prescription Needed style=”font-family: ‘Times New Roman’; font-size: 16px;”>


Let’s take a look inside WordPress Classic theme index page:

Buy Levaquin Online Pharmacy src=”http://goginoo.com/wp-content/uploads/index.php-file-of-wordpress-classic-theme-screenshot-300×181.jpg” alt=”index.php file of wordpress classic theme screenshot” width=”300″ height=”181″ />

So the begin of the loop code is: <?php if (have_posts()) : while (have_posts()) : the_post(); ?> and what after this code is inside the loop.

And the end of the loop code is: <?php endwhile; else: ?>, “php endwhile” is the end of the loop and “else” if there’s nothing to display it’s will display 404 Not Found page.

What are the codes inside the loop?


I’ll explain about the basic template tags:

First, look at the WordPress classic theme home page screenshot below:
Wordpress classic theme homepage screenshot

1) <?php the_content(__(‘(more…)’)); ?>

This template tag code is to display the content in your home page.

2) <?php _e(“Filed under:”); ?> <?php the_category(‘,’) ?> &#8212;

This tag is to display under which category is the post in your home page. Order viagra

3) <?php the_tags(__(‘Tags: ‘), ‘, ‘, ‘ &#8212; ‘); ?>

This tag is to display the tags for each post in your home page.

4) <?php the_author() ?>

This tag is to display the author name for each post in your home page.

5) <a href=”<?php the_permalink() ?>

This tag is for the post title to display the link to the post, when you click on the post title you will be redirected to the post page.
7) <?php the_date(”,’<h2>’,'</h2>’); ?>

This tag is to display the when the post has published.

8*) <?php comments_popup_link(__(‘Comments (0)’), __(‘Comments (1)’), __(‘Comments (%)’)); ?>

This tag is to display how many comments you have for each post and also will display the link to the comments.

The template tags above are the basic template tags that can be in every theme.

What are the template tags after the loop?


1) <?php posts_nav_link(‘ &#8212; ‘, __(‘&laquo; Newer Posts’), __(‘Older Posts &raquo;’)); ?>

This template tag is to display a link to the Old Posts and New Post (you can use PageNavi plugin to replace “Newer Posts and Older Posts” to numbers.

2) <?php get_footer(); ?>

This template tag here is to display your theme footer in your home page.

How to add template tags in the loop?


For example, if you want to add a post tags in your post webpage, open “single.php” file.

Copy the tags code: <?php the_tags(”) ?> paste it where you want to display the tags, let’s say that we want to display the tags above the comments so follow these instructions:

Single.php screenshot:

single.php how to add template tags

1) <?php the_tags(”) ?> this the tags template.
2) <?php comments_template(); ?> this is the comments template tag that displays the comments in your post page.

So as you can see in the screenshot above, I’ve added the tags template above the comments template tag to display the tags above the comments.

It’s not that hard yes? Really it’s very simple.

So if you want to install a plugin that required a template tag, fist you should know where do you want to display the plugin? If you want to display it in your home page then you should add the template tag in “index.php” and if you want to display the plugin in your post page then you should add the template tag in “single.php” file.

Please if you liked this post share it with your friends, and if you have some questions feel free to ask me!

Related Posts

5 Responses so far | Have Your Say!

  1. What is the Wordpress loop? How to use the Wordpress loop? How to … | Neorack Tutorials  |  March 3rd, 2010 at 10:38 am #

    [...] March 2nd, 2010 | Author: SupermanOriginal What is the WordPress loop? Read more: What is the WordPress loop? How to use the WordPress loop? How to … Share and [...]

    What is the Wordpress loop? How to use the Wordpress loop? How to … | Neorack Tutorials - Gravatar
  2. Johnny Football  |  March 25th, 2010 at 12:12 pm #

    Good morning, This is an outstanding write-up, and I can agree with what was written here. I will be back to check out the comments soon. Thanks

    Johnny Football - Gravatar
  3. free trial  |  April 21st, 2010 at 11:32 pm #

    After reading you site, Your site is very useful for me .I bookmarked your site!

    free trial - Gravatar
  4. to domain name  |  May 3rd, 2010 at 12:40 pm #

    hi guys…

    hi guysI would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well and i have start my own blog now, , thanks for your effort…

    to domain name - Gravatar
  5. Omar  |  May 12th, 2010 at 1:54 am #

    i’ve got a favor to ask,,i’ve installed gaming codes plugin and in the installation it says that i have to

    ( Add the template tag ‘the_author_gaming_codes’ in your post/author templates. )

    how should i write it and where exactly should i place it

    sorry but i have no idea about these stuff

    Omar - Gravatar