Get the full commented source code of

HTML5 Suika Watermelon Game

Talking about Php and WordPress.

When your blog starts becoming popular, people will visit, read and talk about it and your blog will have comments pingbacks, and trackbacks.

While everybody knows what is a comment, I am going to explain pingbacks and trackbacks.

From WordPress Codex Glossary:

Pingback lets you notify the author of an article if you link to his article (article on a blog, of course). If the links you include in an article you write on a blog lead to a blog which is pingback-enabled, then the author of that blog gets a notification in the form of a pingback that you linked to his article.

Trackback helps you to notify another author that you wrote something related to what he had written on his blog, even if you don’t have an explicit link to his article. This improves the chances of the other author sitting up and noticing that you gave him credit for something, or that you improved upon something he wrote, or something similar. With pingback and trackback, blogs are interconnected. Think of them as the equivalents of acknowledgements and references at the end of an academic paper, or a chapter in a textbook.

Unfortunately WP’s default theme (and a lot of other themes too) includes comments, pingbacks and trackbacks all together.

It’s not the best solution in my opinion because it would be better to have a main list with only comments, followed by the form to leave a comment and later trackbacks and pingbacks.

In order to do it, we only need get_comment_type() function.

This function returns comment, pingback or trackback according to the type of comment.

So it’s time to edit comments.php file. You will find this file in your theme directory.

Search for

and add below:

to determine whether the current comment is a real comment or not.

Then search for

and add before:

At this time, you will have your comments list containing only comments, and a boolean variable called $i_have_trackbacks set to true if the script found at least a comment that’s a pingback or a trackback.

Now, after the


tag that should close the form used to leave a comment, I repeated the main comment script this way:



Trackbacks

  1. on comment_approved == '0') : ?> Your comment is awaiting moderation.

As you can see from line 1, the scripts is executed only if I found at least a comment that’s a pingback or a trackback, while at line 9 I am looking for comments that aren’t real comments.

My completed comments.php now looks this way

post_password)) { // if there's a password
		if ($_COOKIE['wp-postpass_' . COOKIEHASH] != $post->post_password) {  // and it doesn't match the cookie
			?>

			

This post is password protected. Enter the password to view comments.

to “

  1. on comment_approved == '0') : ?> Your comment is awaiting moderation.
comment_status) : ?>

Comments are closed.

comment_status) : ?>

Leave a Reply

You must be logged in to post a comment.

Logged in as . Logout »




ID); ?>

Trackbacks

  1. on comment_approved == '0') : ?> Your comment is awaiting moderation.

And provides a more user friendly way of displaying comments and trackbacks.

Never miss an update! Subscribe, and I will bother you by email only when a new game or full source code comes out.