To get your WordPress comments customized all you need are the plugins and to use them you need not be a techie or a programmer. You can easily get your polished comment section on your WordPress sites using a few snippets and here are they. Using these snippets, you can earn the advantage of getting the intended results without the site bloating. This article explains how to get rid of the customization problems. You can also see how to correct the issues here. So here is how to customize your WordPress comments using the 5 snippets.
Display number of comments or trackbacks:
Most of the templates have the comment section which begins with the number of comments available in the section. If you want to have a comment tally in any part of the page, then you can make use of this snippet. You can place the comment tally in any place of the single page loop, for example, the top of the page. The template file for this snippet is, content-single.php. The code is:
<?php comments_number(‘no responses’, ‘one response’, %resposnes’); ?>
If you want to be more conversational, then you can use this code:
<p> join the discussion! <?php comments_number(‘ You get to have the first comment!, ‘one comment so far what can you add?, % people have commented – add your two cents!); ?> </p>
Using this code, you can give out apt description in the comments section. You can also replace the strings, if you want to give your own thoughts.
Customize the Default Avatar:
People who visit blog need not be the ones registered with Gravatar, so why do you stick to mystery man for the site, while what is yours is shown as the avatar of the visitors. You can get something unique for your site. The template file for this is functions.php. The raw code to be used is:
Add_filter(‘avatar_defaults’, ‘new default__directory’)./iamges/new_default_avatar.png’; $avatar_default[$new_avatr_url] = ‘My Custom Avatar’; return $avatar_defautls;}
Create your own image and upload in the theme in the image folder. Change the file name to this path and name your avatar.
Go to dashboard and from there go to settings. Go to discussion and you can find the custom avatar there and you can click save and start using your new avatar.
Remover URL and other fields from the contact form:
When you want to remove the unnecessary fields like the website address, which spammers play with, from your contact form, then use this raw code:
Add_filter (‘comment_form_default_fields’, remove_url'); function remove_url($val[‘url’] = ‘’ ; return $val}
Paste the code in the required field and it can be removed. Replace the url with email or author for respective fields.
Keep your blog from pinging itself:
You would not definitely want to get pings when you place links in your own blog. Just add this snippet to rule this out.
Function disable_self _ping(&$links) {foreach($links as $1 => $1) if (0==strops($link, get_option(‘home’))) unset($links[$1]);} add_action(‘pre_ping’, ‘disable_self_ping’);