Multiple WordPress Loops For A New Blog Look
The WordPress blogging software is quite rightly immensely popular. The Open-Source community that supports it has developed a whole raft of supporting code and applications that make it a pleasure to use.
This blog and the other SMM blogs now have a slightly different look. This is because we are now using a feature of WordPress, Multiple Loops. The beauty of WordPress is that the concepts are all very easy to understand. This particular feature will hopefully give much more reader satisfaction.
There are two elements to the change. The first is that you will now only see one blog post when you visit. Although Google tries to be helpful, it can occasionally provide more from a blog that you wish to see. Now you will see precisely the blog post that is relevant to your keyword query.
The other element is that at the bottom of this single blog post you will now see a list of the most popular blog posts as determined by our visitors. If you like what you see in the initial post then perhaps some of the other blog posts may tweak your interest.
The changes to the theme required for this new look are very straightforward. Hopefully this simple explanation will help you apply this same approach to your blog if you so wish.
The WordPress Loop
Web pages in a blog are produced by WordPress templates. These are files with names such as index.php or single.php. Within these template files, the heart of the WordPress software is code which is called The Loop. The WordPress Codex gives a more detailed explanation of The Loop In Action.
The content of all blog posts is held in an associated mySQL database. When a blog web page is displayed, the web page will show certain information for every blog post entry that fits the particular database query implied by your selection of web page. For example, if you want the most recent blog post, then the loop picks up only the information on that blog post. This is illustrated by the following image of a WordPress blog page.

When you visit the home page of the blog, you are often seeing a series of blog posts that are created via the file named index.php. The number of blog posts is selected by the blog webmaster. For example if it is arranged that the blog would normally show the 3 most recent blog posts, then this is illustrated by the following image.

When Google sends you to a single blog post to fit your keyword query then you are often seeing what a file named single.php produces by applying the loop. Normally in the index.php and the single.php files, the loop starts with the following code (note that a space has been inserted after < in the following code samples to ensure the code could be printed.):
< !-- start of the loop --> < ?php if (have_posts()) : ?>
The Loop is then all the code before a final < ?php endif; ?> terminates the Loop (again as mentioned a space has been inserted between < and ? to allow this code to display correctly).
Multiple Loops
As mentioned the new feature is that we are now using Multiple Loops in the WordPress software. The following image shows what is being displayed. The first post is produced by a first Loop. The list of Most Popular Posts is then produced by a second Loop.

In order to have only one post appear in the first loop, we use a Template Tag, query_posts. This query_posts tag can modify what the Loop accesses from the database. In this case we wish to have only one blog post to appear so the first Loop starts off as follows:
< !-- start of first loop -->
< ?php query_posts('showposts=1');
if (have_posts()) : ?>
The only complication here is that as entries are taken from database in The Loop, the database software maintains a count of the data that has been used. Normally other applications of the Loop will access only new data since past data has already been accessed. In order to see the posts which are of interest, we use another WordPress Template Tag as the second Loop starts to reset the count. This tag is the rewind_posts tag.
In order for the list of Most Popular Posts to be displayed, a new category, popular, has been created. When visitor traffic confirms that a blog post is popular, then it is assigned to this category in addition to whatever category may have been appropriate.
The code to start the second Loop to achieve the effect shown here is as follows:
< !-- start of second loop -->
< ?php rewind_posts();
query_posts('category_name=popular&showposts=-1');
if (have_posts()) : ?>
Other Benefits Of This Type of Display
In addition to displaying popular posts for greater visitor satisfaction, this also ensures that such posts have more links pointing to them. This should ensure greater search engine visibility for these posts. In all, this format would seem to have only benefits. It will be interesting to see what reactions blog visitors have to this new format.








Go To Top

in the SEO Services Marketplace








May 17th, 2009 at 8:50 pm
Nice post, Barry. One of the really neat things about WordPress for non programmers is that you don’t need to learn programming to do programming-like things – WordPress’s Template Tags does it for you.
May 18th, 2009 at 5:22 am
Nice post more informative things in this.Nice structure explanation.
May 18th, 2009 at 8:55 pm
I have a drupal site but this really helps as well. Thank you very much for the article.
May 18th, 2009 at 10:28 pm
This is one of the reason why I consider wordpress as one of the recommendable blog platform for beginners to experts.
The idea of rolling content and displaying it on related recent post would help both the blog site and the visitor know what there is to offer. An old post couldn’t possible get traffic anymore not unless it’s glued on the first page of SERP for a certain beneficial set keywords. But this multiple loop would give another chance for an old post to be viewed once it’s displayed as a related to the recent post.
May 19th, 2009 at 5:59 am
A very good post Barry, I have often had many problems in wordpress formatting and have bookmarked this post for future reference.
Keep up the good work pal, subscribing now
May 19th, 2009 at 8:20 am
Great explanation, I have been seeing this sort of thing in many blogs lately and didn’t really know how they do it. And I have noticed that I do often click on the links to the popular posts at the bottom, so this technique does make me, as a reader, stay on a blog longer and read more.
May 19th, 2009 at 6:26 pm
Appreciate the information. I had never noticed this before but in hindsight it is obvious. I will implement on some of my blogs & monitor the results.
May 19th, 2009 at 7:27 pm
I agree, The WordPress blogging software is quite rightly immensely popular.
thanks for sharing.
May 20th, 2009 at 1:57 am
“In addition to displaying popular posts for greater visitor satisfaction, this also ensures that such posts have more links pointing to them. This should ensure greater search engine visibility for these posts. In all, this format would seem to have only benefits. It will be interesting to see what reactions blog visitors have to this new format.”
This is a great concept, very well explained, thank you! For my 2c worth, I would have to say that the new format can only help to enrich the viewer’s experience, and give them more reason to stay on the site longer (which is what we all want, isn’t it?).
Great post!
May 20th, 2009 at 6:00 am
[...] A blog post giving details on this multiple loops approach [...]
May 20th, 2009 at 7:18 am
Nice post, Barry. One of the really neat things about WordPress.
thanks
May 20th, 2009 at 8:23 am
I am just starting to use WordPress. I took me a little white to get used to how it worked, but I am finding that I like it more and more. Thanks for posting Barry!
May 21st, 2009 at 7:33 am
Yeah, using multiple loops in wordpress has really helped me break out of that common default theme look and experiment with new displays.
May 21st, 2009 at 8:47 pm
Fresh and original ideas — Thanks!
May 22nd, 2009 at 7:58 am
Nice post, Barry. One of the really neat things about WordPress for non programmers is that you don’t need to learn programming to do programming-like things – WordPress’s Template Tags does it for you.
May 22nd, 2009 at 12:38 pm
I’m a fan of displaying multiple posts because mine are often related and sometimes won’t even make sense without a previous one.
May 22nd, 2009 at 1:31 pm
I’ve started learning the ins and outs of WordPress 2.8 Beta, and will have to start looking for templates soon. I will take this post’s advice to heart and try shake things up a bit instead of using themes as-is. Thanx!
May 22nd, 2009 at 2:23 pm
That’s an interesting point, Alfred. However most people arriving via a Google search will only see a single post anyway. Only the small minority of visitors who come in via the ‘front door’ will see as many posts as you have arranged in your blog ‘home’ page.
June 4th, 2009 at 3:02 am
Interesting thoughts Barry and not something I have seen discuussed elsewhere despite it’s importance and relevence.
It’s interesting watching wp morph from a blog platform towards a more standard type of traditional website ( albeit a powerful one )
Andrew.Australia.
June 8th, 2009 at 8:23 am
I just got done building the new wordpress theme for my site. I will probably put it live next week. But to be honest it was a blast to build. WordPress really does make it easy and fun to build their blogs.
June 9th, 2009 at 5:20 am
Great ideas, great loops