Frances Lui dot COM

Make Money, WordPress Tips, Good Deals, Freebies and Health Tips

  Recommended 
  Money Makers 

Text Link Ads TTZ Media Bidvertiser
DealDotCom Shopping Ads Shopping Ads

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:

  1. Open the comments.php file for your template.
  2. Look for the comment loop in the comments.php file. In my comments.php, the comment loop starts with
    <?php foreach ($comments as $comment) : ?>
  3. Add the following code right after the comment loop begins:
    <?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.

  4. Add an if-statement inside of your comment loop so that only normal comments are shown. To do this, you need to wrap all of your original code inside of the comment loop between the new if-statement:
    <?php if ($comment_type == 'comment') { ?>
       <!-- your original code inside of the comment loop -->
    <?php } ?>
  5. Now, you are showing only normal comments. Make a copy of your new comment loop so that you have two comment loops, one on top of the other. The only thing you need to do in the second loop is to change the if-statement from:
    <?php if ($comment_type == 'comment') { ?>

    to

    <?php if ($comment_type == 'pingback') { ?>

    for showing pingbacks in the second loop.

  6. Do the same thing as in the above step for trackbacks. Make a copy of your new comment loop for normal comments so that you now have three comment loops, one on top of the other. The only thing you need to do in the third loop is to change the if-statement from:
    <?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.

Save to del.icio.us Submit To Propeller
   

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.

Save to del.icio.us Submit To Propeller
   

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:

  1. In the WordPress admin area, go to the Options -> General tab.
  2. In the WordPress address (URL) field, put your WordPress directory. For example: http://www.your-domain.com/wordpress
  3. In the Blog address (URL) field, put your root directory. For example: http://www.your-domain.com
  4. Click the Update Options button to save your changes.
  5. Copy the index.php and .htaccess files from your WordPress directory to your root directory.
  6. Open your root directory’s index.php file in a text editor.
  7. Change the line from
    require(’./wp-blog-header.php’);
    to
    require(’./wordpress/wp-blog-header.php’);
  8. Now, your blog should be in the root directory and you can login to the WordPress admin area at http://www.your-domain.com/wordpress/wp-admin/

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.

Save to del.icio.us Submit To Propeller
   
Page 1 of 212»

Subscribe to Frances Lui dot COM

Recent Readers