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>
<?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) {
$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 } } ?>

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? :)

How to Display Categories in Drop-Down Box

Personally, I prefer to display my blog categories without in drop down box, but if you really have many categories on your blog, perhaps you can display categories in drop-down box so that your blog will looks more neat.

Below is the simple code to display categories:-

<?php wp_list_cats('sort_column=name'); ?>

To display categories in drop-down box, use the following code.

<form action="<?php bloginfo('url'); ?>/" method="get">
$select = wp_dropdown_categories('show_option_none=Select category&show_count=1&orderby=name&echo=0');
$select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); echo $select; ?>
<noscript><input type="submit" value="View" /></noscript>

Managed and Outsource Printing

I remembered the first time I worked in office as a executive staff, I have learned to operate the printer equipment when I want to print my documents. Not only me, my colleagues that  working in the office also need to learn how to operate the printer equipment. This already consumed our time and will not leave us for other strategic tasks. I was thinking that my boss should look for print outsourcing in order to save some money and increase efficiency at the same time. Perhaps my boss don’t know, sometimes I really spent 1-2 hours stand in front of the printer machine just to print my documents.

My old company also deal with printing company quarterly as we need them to print our company brochure and catalog for marketing strategy and promotion purpose. When the time we want to participate in trade show, we will order lots of promotional items which printed with company name. You can see when we run a business, especially big business like my old company, we will need the help of printing company.

It can be very frustrating when choosing a printing company, almost every company that have computer and printer could start a printing house. First of all, you need to know what your printing requirements are and how a printing organization can fulfill these demands.

For those people who are looking for printing company and located in Dollas, Texas, perhaps you can look for as offers print supply chain solutions, commercial printing and fulfillment services. Whether you are looking for printing service, printing outsourcing, printing procurement solution and company store, fulfillment service and etc, has all of them. Be confidence with, study their case studies then you will know how professional they are.

All right, after read this post, don’t forget to give a visit, thank!

How to Prevent Images on Posts from Being Too Large

Everyone will put images on the posts, sometimes the images displayed on the posts looks too large and may be break your current theme layout, it isn’t nice. There is a solution to avoid this problem with the help of adding the following code to your style.css file.

What you need to do is open style.css file, and simply copy and paste the following code to this file.

.post img {
max-width: 540px; /* Adjust this value according to your content area size*/
height: auto;

Most wordpress themes display posts content within a tag. In case this doesn’t work, you can try another way as below.

.maxwidth img {
max-width: 540px; /* Adjust this value according to your content area size*/
height: auto;

Use class=”maxwidth” on your IMG element. For example,

<img src="”../images/abc.jpg”" class="maxwidth" />

Hotlink Protection – Protect Your Images Being Hotlink in Other Places

No people like their images of their blogs being hotlink in other places, because this will increase your bandwidth usage and slow down the speed of your blog. In order to avoid your images being hotlink by other people, you can use Hotlink Protection wordpress plugin to protect it.

How It Works

  • Referrer check if someone requests an image from your blog. If the referrer is not empty and not your blog the request is redirected to an information image
  • The image urls in the feed are replaced by an alternate url. This url is not protected by a referrer check so online feedreaders get the image

What It Not Does

  • It doesn’t protect the images in the feed. So hotlinking the image urls from the feed is possible. But in my opinion it is nearly impossible to protect this images without breaking some online feedreaders.
  • It doesn’t prevent someone from downloading your images and placing them on their own webspace

How to Display Google Adsense After The First Post

If you want to display Google Adsense After the first post, then you can refer to the following code and see how it works. Honestly, this is a wonderful code that I have been looking for so long.

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); $loopcounter++; ?>

// the loop stuffs

<?php if ($loopcounter <= 1) { include (TEMPLATEPATH . '/ad.php'); } ?>

<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>

Thanks Web Designer Wall for this awesome code.

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);
Page 10 of 41« First...9101112...Last »

Error. Page cannot be displayed. Please contact your service provider for more details. (2)