Inline Trackbacks Hack
-
I had a client for Elegant Webscapes request inline trackbacks. I did a search and found none posted in either the WordPress Hacks or WordPress Plugin pages. So, I decided to write one.
- Copy the following code into your my-hacks.php file.
- Include this tag
< ?php inline_trackback('', 50, '<br />'); ?>on your index.php file where you want the inline trackbacks to appear.
function inline_trackback($before = ‘’, $limit = 50, $sep = ‘‘) {global $wpdb, $tablecomments, $id;
$request = "SELECT comment_author, comment_author_url, MAX(comment_ID) as comment_ID, SUBSTRING_INDEX(comment_content,’strong’,2) as trackback_title FROM wp_comments";
$request .= " WHERE comment_post_ID=’$id’ AND comment_approved = ‘1′ AND comment_content LIKE ‘%trackback /%’ GROUP BY comment_author, comment_author_url ORDER BY comment_ID DESC";
$request .= ($limit > 0) ? " LIMIT $limit" : ‘’;
$commenters = $wpdb->get_results($request);if ($commenters) {
$output = ‘’;
foreach ($commenters as $commenter) {
if (!empty($commenter->comment_author_url)) {
$output[] = $commenter->comment_author . ‘ linked with comment_author_url . ‘� title="‘ . $commenter->comment_author . ‘">’ . $commenter->trackback_title . ‘‘ . ‘’;
}
else {
$output[] = $commenter->comment_author;
}
}if (is_array($output)) {
echo $before.implode($sep, $output);
}}
The topic ‘Inline Trackbacks Hack’ is closed to new replies.