I recently wrote that I don’t like Top Commenters plugins, in fact I used a very strong word… loathe. There are some benefits to introducing Top Commenters to give some level of special recognition, but whatever SEO benefits you think it might offer are discounted by having it placed in your sidebar across the whole of your site including your duplicate content pages.
What you give with one hand you take away with another
If you are giving away all your Google Juice from your sidebar, then you get less juice for
- Your own pages
- The links to sites in your content
- The links from your comments
This isn’t just a problem with Top Commenters, it is also the same with blogrolls, and I have discussed that in the past as well.
There is some WordPress Logic you can use for all page elements depending on whether you are using widgets or not.
If you are using widgets, you would probably have to use a variant of the text entry box that allows PHP – I don’t monitor developments with WordPress widgets too much, but in the past I have found the way they are implemented in most themes to be too much hard work to customize where things appear, and on which pages. I don’t know of a version of widgets that allows drag-and-drop and total control over the placement of widgets on specific pages.
If you are using normal sidebar.php code, then you can use something like the following code.
There are a number of Top Commenters plugins, I have just grabbed the code insert from one example.
<?php if ( is_home() ) { ?> < ?php if(function_exists('fp_get_topcommenters')) { echo fp_get_topcommenters(); } ?> <?php } ?>
If you wanted the Top Commenters to appear on both your homepage and your single pages (the ones that permalinks point to), then you would use something like this:-
<?php if ( is_home() || is_single() ) { ?> < ?php if(function_exists('fp_get_topcommenters')) { echo fp_get_topcommenters(); } ?> <?php } ?>
There are lots of conditional flags that can be used within WordPress in this manner. Here are some others but it might not be an exhaustive list.
is_home()
is_paged()
is_search()
is_attachment()
is_single()
is_category()
is_author()
is_archive()
is_404()
There is also a function with Ultimate Tag Warrior, but you should ensure that UTW is installed in the same statement just in case you switch it off.
<?php if ( function_exists('is_tag') and is_tag() ) : ?>
Most themes already use similar code for various elements for the sidebar and in the headers.
Watch out for multiple occurrences of the logic in various files such as
sidebar.php
home.php
index.php
tags.php
single.php
page.php
archives.php
Some themes just include the sidebar.php on all pages. In this case you might have to use lots of nested logic to achieve the level of control you require.
Other themes only use sidebar.php on pages that use index.php, and have custom code for single.php – this allows you to use slightly less logic, but means you have to edit code in multiple places.
The post How to Show Top Commenters Only On Your Index Page appeared first on Internet Business & Marketing Strategy - Andy Beard.