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 = a€?a€?, $limit = 50, $sep = a€?a€?) {
global $wpdb, $tablecomments, $id;
$request = "SELECT comment_author, comment_author_url, MAX(comment_ID) as comment_ID, SUBSTRING_INDEX(comment_content,a€?stronga€?,2) as trackback_title FROM wp_comments";
$request .= " WHERE comment_post_ID=a€?$ida€? AND comment_approved = a€?1a€2 AND comment_content LIKE a€?%trackback /%a€? GROUP BY comment_author, comment_author_url ORDER BY comment_ID DESC";
$request .= ($limit > 0) ? " LIMIT $limit" : a€?a€?;
$commenters = $wpdb->get_results($request);if ($commenters) {
$output = a€?a€?;
foreach ($commenters as $commenter) {
if (!empty($commenter->comment_author_url)) {
$output[] = $commenter->comment_author . a€? linked with comment_author_url . a€?a€? title="a€? . $commenter->comment_author . a€?">a€? . $commenter->trackback_title . a€?a€? . a€?a€?;
}
else {
$output[] = $commenter->comment_author;
}
}if (is_array($output)) {
echo $before.implode($sep, $output);
}}
- The topic ‘Inline Trackbacks Hack’ is closed to new replies.