How to Avoid Duplicated Comments Submitted

This is one way to combat spam comments if you can avoid duplicated comments are submitted on your posts, you can do some code modification as below in comments.php file. Why people post double comments because sometimes they are not aware that their comment is under moderation mode. Anyway, if you found your theme don’t have this option, then you can open comments.php and do some code modification.

1. Open comments.php and find the following code.

<p>
<input name="submit" type="submit" tabindex="5" value="<?php _e("Say it!"); ?>" />
</p>

2. Replace with

<p>
<blockquote>
Comment moderation is in use. Please do not submit your comment twice — it will appear shortly.
</blockquote>
<input name="submit" type="submit" tabindex="5" value="<?php _e("Say it!"); ?>" />
</p>

How to Display Feedburner Subscribers in Plain Text

Feedburner came with feed count banner, but if you think this banner doesn’t match your website design or you want to display Feedburner subscribers in plain text, this is possible!

Copy and paste the following code into your template, for example sidebar.php, replace feedburner-id with your Feedbuner username. This script will grab you the feed count in numbers.

//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=feedburner-id";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
//end get cool feedburner count

Now paste this anywhere you want and it’ll display a Feedburner subscriber count in text.

echo $fb;

Source Link

How to Make Your Title Tag SEO Friendly

Wordpress title tag also plays important role in SEO, it telling the search engine spider what your site covered, and allows your site to be indexed based upon the correct and most relevant keywords. If your site has good seo, then you will have lots of organic traffic from various search engines. So how to make your wordpress title tag SEO friendly?

Open header.php file, find the <title> tag, and replace it by the following code.

<title>
<?php if (is_home () ) {
bloginfo('name');
} elseif ( is_category() ) {
single_cat_title(); echo ‘ – ‘ ; bloginfo('name');
} elseif (is_single() ) {
single_post_title();
} elseif (is_page() ) {
bloginfo(’name’); echo ': '; single_post_title();
} else {
wp_title("",true);
} ?>
</title>

This code will generate title tags according to the following model:

  • Blog homepage -> display blog name.
  • Category page -> display the category name and the blog name.
  • Article page -> display the article title.
  • Static page -> display the blog name, and the page title.

How to Display Random Posts on Your Sidebar

Many readers seldom browse through our old post to read them out, but installing wordpress plugin like Pagenavi and Related Posts can help to give a new life for your old posts. There is another way to make your old posts have a good chance to read by reader, that is to display random posts on your sidebar.

To display random posts on your sidebar, simply copy and paste the following code to your sidebar.php.

<?php
query_posts(array('orderby' => 'rand', 'showposts' => 1));
if (have_posts()) :
while (have_posts()) : the_post();
the_title();
the_excerpt();
endwhile;
endif; ?>

How to Display Most Recent Twitter Tweets in WordPress Blog

Since Twitter became popular, many bloggers like to display recent twitter tweets on their website or blog. To display most recent twitter tweets, simply copy and paste the following code to your sidebar.php file.

<?php
// Your twitter username.
$username = "TwitterUsername";
// Prefix - some text you want displayed before your latest tweet.
// (HTML is OK, but be sure to escape quotes with backslashes: for example href=\"link.html\")
$prefix = "";
// Suffix - some text you want display after your latest tweet. (Same rules as the prefix.)
$suffix = "";
$feed = "http://search.twitter.com/search.atom?q=from:" . $username . "&rpp=1";
function parse_feed($feed) {
$stepOne = explode("<content type=\"html\">", $feed);
$stepTwo = explode("</content>", $stepOne[1]);
$tweet = $stepTwo[0];
$tweet = str_replace(”&lt;”, “<”, $tweet);
$tweet = str_replace(”&gt;”, “>”, $tweet);
return $tweet;
}
$twitterFeed = file_get_contents($feed);
echo stripslashes($prefix) . parse_feed($twitterFeed) . stripslashes($suffix);
?>

Thanks the awesome code from WP Hacks.

How to Create Meta Description Function and Meta Keyword Tags

If you want to create meta description function and meta keyword tags for your wordpress themes, open header.php file and then copy and paste the following code within <head> and </head>.

<meta name="description" content="
<?php if ( (is_home()) || (is_front_page()) ) {
echo ('Your main description goes here');
} elseif(is_category()) {
echo category_description();
} elseif(is_tag()) {
echo '-tag archive page for this blog' . single_tag_title();
} elseif(is_month()) {
echo 'archive page for this blog' . the_time('F, Y');
} else {
echo get_post_meta($post->ID, "Metadescription", true);
}?>">

Thanks the original function from Malcolm Coles.