19 Jan 2008
Posted by Frances Lui in WordPress How-To
When you receive some pingbacks or trackbacks from other bloggers’ posts, they will appear as regular comments under the comment section of your post if you don’t separate them from normal comments. If you have a lot of comments from your readers, it is hard to locate them.
When pingbacks and trackbacks are separated from comments, your post looks nicer and cleaner. Also, your readers can find out immediately if your post contains any pingbacks or trackbacks.
To separate pingbacks and trackbacks from normal comments, do the followings:
<?php foreach ($comments as $comment) : ?>
<?php $comment_type = get_comment_type(); ?>
My comments.php now looks like:
<?php foreach ($comments as $comment) : ?><?php $comment_type = get_comment_type(); ?>
This will make the $comment_type variable available so that you can place an if-statement to determine if the comment is a normal comment, pingback, or trackback.
<?php if ($comment_type == 'comment') { ?><!-- your original code inside of the comment loop --><?php } ?>
<?php if ($comment_type == 'comment') { ?>
to
<?php if ($comment_type == 'pingback') { ?>
for showing pingbacks in the second loop.
<?php if ($comment_type == 'comment') { ?>
to
<?php if ($comment_type == 'trackback‘) { ?>
for showing trackbacks in the third loop.
After following all of the above steps, your new comments.php file should look something like:
<?php foreach ($comments as $comment) : ?><?php $comment_type = get_comment_type(); ?><?php if ($comment_type == 'comment') { ?><!-- your original code inside of the comment loop --><?php } ?><?php endforeach; ?><?php foreach ($comments as $comment) : ?><?php $comment_type = get_comment_type(); ?><?php if ($comment_type == 'pingback') { ?><!-- your original code inside of the comment loop --><?php } ?><?php endforeach; ?><?php foreach ($comments as $comment) : ?><?php $comment_type = get_comment_type(); ?><?php if ($comment_type == 'pingback') { ?><!-- your original code inside of the comment loop --><?php } ?><?php endforeach; ?>
As you can see, it is not difficult to separate pingbacks and trackbacks from normal comments. If you have any questions or comments, feel free to leave me a comment.
If you like this post and want to read more, please subscribe to my full feed RSS.31 Dec 2007
Posted by Frances Lui in WordPress How-To, WordPress Plugin
Google Analytics makes it easy for us to learn more about where our visitors come from and how they interact with our website. Also, it is the best one we can get for free.
However, according to the documentation from Google Analytics, we need to copy and paste tracking code into all of the web pages we would like to track. It would be very inconvenient if we followed this documentation.
Fortunately, we can make use of the Google Analytics plugin from Semiologic to put the tracking code automatically for us. Installing it is very similar to installing other Wordpress plugins. All you need to do is to follow the simple installation procedures specific to this plugin. Because it takes some time to collect enough data to create your website report, if you just create an Google Analytics account, you need to wait for about one day in order to see your report.
If you like this post and want to read more, please subscribe to my full feed RSS.18 Dec 2007
Posted by Frances Lui in WordPress How-To
Most bloggers make WordPress power their websites’ root directories. However, it is not a good idea to put all WordPress files in a website’s root directory because it is hard to manage if we would like to move our blogs to somewhere else in the future.
WordPress allows us to put WordPress files to a directory and have a blog located in a website’s root.
You can let WordPress have its own directory by following these simple steps:
If you have any questions or comments, please don’t hesitate to leave me a comment.
If you like this post and want to read more, please subscribe to my full feed RSS.
Subscribe to Frances Lui dot COM