Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

ckrets on "Recent Comments in sidebar no longer"

$
0
0

I'm not sure if I posted this in the right section, just because the code that I was using was FROM a plugin,...sorry if I should have posted this elsewhere!

So I upgraded my WordPress to the newest version. I was using the following code with no issues before updating to 4.2.4:

<?php
$number=5; // number of recent comments desired
$comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number");
?>
<ul id="recentcomments">
<h2>Recent Comments</h2>
<?php
if ( $comments ) : foreach ( (array) $comments as $comment) :
echo  '<li class="recentcomments">' . sprintf(__('%1$s on %2$s'), get_comment_author_link(), '<a href="'. get_comment_link($comment->comment_ID) . '">' . get_the_title($comment->comment_post_ID) . '</a>') . '</li>';
endforeach; endif;?></ul>

Which I got from here. After updating WordPress, I keep getting the following error message in my sidebar (and the error message comes up in place of my sidebar):

Parse error: syntax error, unexpected T_VARIABLE in "sidebar.php" on line 1

When I remove the code from my sidebar, my sidebar shows fine. Is there any other manual PHP code I can use that will give me the same result as the one above?


Viewing all articles
Browse latest Browse all 8245

Trending Articles