Quick Maintenance Mode on Your WordPress Blog

If you want to do some maintenance on your WordPress blog, and you want to let your visitors know that your blog is down for maintenance, then you have 2 methods to do that.

The first method is that you can adds a splash page to your blog that lets visitors know your blog is down for maintenance by using Maintenance Mode WordPress plugin, this method is easy for WordPress beginner.

Another method is quite simply for advance WordPress users, just copy and paste the following code to functions.php will do. Don’t forget to remove the code once you are done with maintenance.

function wpr_maintenance_mode() {
    if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
        wp_die('Maintenance, please come back soon.');
    }
}
add_action('get_header', 'wpr_maintenance_mode');

How to Optimize WordPress Database Easily

We need to optimize WordPress database for some period of time due to the useless data “overhead” piles up over the years and slows your database down, sometimes the database may be get crashed too. There are 2 easy method to optimize WordPress database, one of the method is using WordPress plugin and another one is through phpMyAdmin.

Method 1: Optimize DB plugin

For those beginner user of WordPress, I suggest you use Optimize DB plugin to optimize your WordPress database as it is easy to use. Just upload Optimize DB plugin to your WordPress plugin folder, activate it then you can start using it.

Method 2: phpMyAdmin

  1. Login to Cpanel, go to phpMyAdmin
  2. Refer the to screenshot below, select your database that you want to optimize, check all the tables, and then select “optimize table” from the dropdown box.


Warning: Always backup your full database before attempting any database changes. In case you do something wrong, you can restore back your database.

How to Insert Facebook “Like” Button on Your WordPress Blog

Lots of people are using Facebook now, so inserting Facebook “Like” button on your blogs is one of the best ways to increase your blog traffic. When people clicking on Facebook “Like” button on your blog posts, then your blog posts will be automatically shared on their Facebook and indirectly promoting your blog post to their friends.

There are two methods to insert Facebook “Like” button on your blogs, you can try the easy way which using iFrame, and another complicated method is using XFBML and JavaScript SDK. To insert the Facebook “Like” button on your blogs (iFrame), copy and paste the following coding to your WordPress file single.php will do!

<iframe src="http://www.facebook.com/plugins/like.php?href=<?php  the_permalink()  ?>&amp;layout=standard&amp;show_faces=false&amp;width=600&amp;action=like&amp;font=verdana&amp;colorscheme=light&amp;height=35"  scrolling="no" frameborder="0" style="border:none; overflow:hidden;  width:600px; height:35px;" allowTransparency="true"></iframe>

Render Your WordPress Blogs on Mobile Handsets with MobilePress WP Plugin

Smartphone like iPhone and Android are became so popular and widely used by many people nowadays, I’m also one of them is using iPhone right now. When the time I’m surfing to the Internet using my iPhone, I found there are lots of websites have using the same themes like what I have browse by using computer. Since the screen display of the phone has limitation, normally I can’t read what we want properly due to the layout, font size, button of the websites and etc, and this may cause to the downloading time become so long.

For those people who have WordPress blogs and you want to render your WordPress blogs on mobile handsets, with the ability to use customized mobile themes, track ana, perhaps you can using MobilePress WordPress plugin. You can create custom mobile themes for MobilePress enabled blogs.

MobilePress is SEO enabled and detects Google, Yahoo and MSN mobile search bots. These mobile search engine bots will see the mobile version of your blog and get your mobile site indexed in the mobile search results.

How to Create Page Templates

Normally I will use page templates to display the archives which will list all posts on my blog, anyway you can use page templates to get specialized results apart from the basic static page template.

What you need to do is to add the following code to the first line of your php files, you can change the template name as you wish.

<?php
/*
Template Name: Archives
*/
?>

So now, you have to create a page template named Archives. Then, create a new page, find Template drop down box (refer picture) and choose Archives, this is a page template named Archives that you have created just now.

How to Display the Total Number of Comments on Your Blog

Who don’t like to have comments on your blog? If your blog has many comments, it can be say that your blogs is popular, at least people like to interact with you to ask question and share information with you. If you really proud with your total number of comments on your blog, and want to show off to visitors.

To display the total number of comments on your blog, simple add the following code to your wordpress files.

<?php
$numcomms = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->comments WHERE comment_approved = '1'");
if (0 < $numcomms)  $numcomms = number_format($numcomms);
echo "There's ".$numcomms." total comments on my blog";
?>

Special thanks to PHP Magic Book for this awesome code.

Remove WordPress 3.1 Admin Bar

WordPress 3.1 has introduced a new feature admin bar, I believe that some people will like it and some don’t like, and I’m the one who also don’t like admin bar and thinking to remove it because it is annoying. For those people who want to remove WordPress 3.1 admin bar, you can follow the below step to remove it.

Copy and paste the following coding to functions.php and done!

wp_deregister_script('admin-bar');
wp_deregister_style('admin-bar');
remove_action('wp_footer','wp_admin_bar_render',1000);

TwiBadge – Show Your Twitter Badge with Easy Personalization

TwiBadge is a wordpress plugin to show your Twitter badge with easy personalization, it display all your tweets and replies from twitter.com/home. Apart from that, this plugin also came with a “follow” button which allows visitor to follow on your twitter.

Below is some features of this plugin:-

  • Integrate Twitter and WordPress seamlessly
  • Show Twitter badge as a WordPress widget
  • Support flash interactive widget
  • Easy personalization, no coding knowledge is needed
  • Support shortcode
  • Support non-widget theme

How to Display Most Popular Posts Without a WordPress Plugin

Many blogs have display most popular posts on their blog to make visitors stay longer on their posts, this is one of the way to attract more visitors to your blog. We actually can install a wordpress popular posts plugin to display our most popular posts, but if you don’t want to use plugin, you can simply hack your wordpress theme to do it manually.

Copy and paste the following code to the sidebar.php file, if you want to change the number of displayed posts, simply change the “5″ to your desired number.

<h2>Popular Posts</h2>
<ul>
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5");
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li><a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
<?php echo $title ?></a> {<?php echo $commentcount ?>}</li>
<?php } } ?>
</ul>

Please note that the 5 most popular posts displayed is basing on the 5 most commented posts .

How to Add Avatar to Your Comments

The default wordpress themes are came with avatar support. In case you have use some other free or premium wordpress themes with no avatar support, then you can adding the following simple and short coding to your comment.

<?php echo get_avatar( get_the_author_email(),  '80'); ?>

get_the_author_email outputs the post author’s email and the “80” is the size of the avatar image in pixels, you can change the size of the avatar according to your needs. Is it looks simple? :)

Calling cards for domestic and international use, great rates and excellent connectivity.
International prepaid phone card plans offer the ultimate in convenience for phone card users at the lowest cost available.
Australia international calling cards for low-cost international calls from United States to Australia.