Setup trackback - Blog entry page

15 August 2009

The blog page needs to show the trackback URL, for people sending a trackback to use, and also display the current trackbacks for this page.

Near the bottom of a lot of blog entries you'll often find a comments area.

Because trackbacks are another way of interacting with the page they're usually found around the same area as the commenting area.

It should show the current trackbacks – like this code that I use:

$track_query = "SELECT url,date,excerpt,blog_name,title FROM trackbacks WHERE blog_id = '" . $blog['id'] . "' AND url <> ''";
$track_result = mysql_query($track_query);
if (mysql_num_rows($track_result) > 0)

echo "<p>Current trackbacks to this blog entry are</p>";
while ($track = mysql_fetch_array($track_result))

echo "<p style="padding-left:30px;"><strong>" . display_string($track['title']) . "</strong> on <strong>" . display_string($track['blog_name']) . "</strong><br /> " . display_string($track['excerpt']) . "<br /><a href="" . $track['url'] . "" target="_blank" rel="nofollow">" . str_replace("http://","",$track['url']) . "</a></p>";



You will probably need to change some of the query string as you may not be passing in the same variables as I have already set.

$blog['id'] needs to be the id for the blog entry so that it only shows the trackbacks for that one blog entry.

Showing the trackback URL for a particular blog entry can be done by:

$site_url = “”;
$trackback_page = “trackback.php”;
$trackback_url = $site_url . $trackback_page . “?id=” . $blog['id'];

As you can see because of the $blog['id'] variable, every blog entry will have a unique trackback URL address.

Please leave a comment using the form provided.