Category Archives: Wordpress

WordPress – Display Total Number of SQL Queries on Your Blog

Queries are evil. They slow down your site as you begin to accumulate more, which can negatively effect the user experience.
In fact, Google agrees too.

The first step to lowering queries is to know how many you actually have. Simply paste the following line of code somewhere on your site. I prefer going after the footer.php file.

<?php if (is_user_logged_in()) { ?>
    <?php echo get_num_queries(); ?> queries in <?php timer_stop(1); ?> seconds.
<?php } ?>

If you want this to be publicly shown, simply remove lines 1 and 3.

WordPress – Adding Comment Numbers To Your Theme

I’ve noticed a lot of themes that don’t come with numbers on the blog’s comments.

This might not be such a bad thing if you don’t get very many comments, but if your blog does get comments it is probably a good idea to show off how many comments you get by numbering them.

Here are the steps you can take to easily add numbers to your WordPress theme’s comments section.

First thing you will want to do is create a backup your comments.php file.
Locate the comments.php file.
Locate the code that starts the comment loop. It will look something like this:

<?php if ( $comments ) : ?>

Place this code immediately above the code in Step 3:

<?php $i = 0; ?>

Now locate the code that looks like this:

<?php foreach ($comments as $comment) : ?>

Placed this code immediately below the code in Step 5:

<?php $i++; ?>

Now use this code where you want to display your comment numbers:

<span>
<?php echo $i; ?>
</span>

Click Save.

Now go to your stylesheet (style.css) and place this code anywhere on the stylesheet (probably best placed in the comments section):

.count {
float:right;
padding: 10px;
font-size:18px;
color:#000000;
}

You can adjust the stylesheet to fit your comment numbers into the placement and appearance that you want them to have.

 

 

WordPress – Add Del.icio.us Daily Blog Posting To Your WordPress Blog

Have you ever noticed that many blogs put up a daily post that is simply a bunch of links to other websites?
This is actually done automatically, and if you have ever wondered how to set that up, you’ve come to the right place. That feature is called Del.icio.us Daily Blog Posting, and this post will explain how to accomplish this if you have a self-hosted WordPress blog.

First thing you need is to sign up for an account with the popular social bookmarking service Del.icio.us. The account is free and allows you to store your bookmarks online in a nice and convenient location. Once you’re registered and ready to set up your daily blog posting feature, you’ll want to follow these easy steps:

Read more »

WordPress – How to List Your Upcoming Posts

If you want to display your schedule posts in a list which can often help readers to give them heads up about what you’re going to publish in upcoming days.

This can also help you to get new visitors and some more RSS subscribers. It’s not very hard to implement this functionality as it seems.

Read more »

WordPress – Allow only your IP adress on the wp-admin directory

Excepted the case of a collaborative blog, only you should be allowed to visit the wp-admin directory. If you have a static IP, this code will do the job.

All you have to do is to enter your static IP adress on line 8 in your htaccess file.

Note that you can add more IPs if needed, by creating a new line with: allow from xx.xx.xxx.xx inside.

AuthUserFile /dev/null
AuthGroupFile /dev/null
AuthName "Example Access Control"
AuthType Basic
<LIMIT GET>
order allow, deny
deny from all
allow from xx.xx.xx.xx
</LIMIT>