Widget commands
-
I have been tweaking a theme that I like, but I have come to a point that I need someone’s help. Currently, my sidebar is custom made by the original designer and shows three boxes: tags, recent comments, and “Popular” posts (popular is defined by how many comments are on a given post).
I want to change the “Popular” box to show the most recent posts published in order. In the theme editor, the sidebar file has a div id – “Popular”, which I believe is getting instructions from the themes function file. From the themes function file, I found this:
<?php
function popularPosts($num) {
global $wpdb;$posts = $wpdb->get_results(“SELECT comment_count, ID, post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , $num”);
foreach ($posts as $post) {
setup_postdata($post);
$id = $post->ID;
$title = $post->post_title;
$count = $post->comment_count;if ($count != 0) {
$popular .= ‘- ‘;
$popular .= ‘‘ . $title . ‘ ‘;
$popular .= ‘
‘;
}
}
return $popular;Can anyone tell me what I need to change to make this function collect and display the most recent posts? Thanks!
- ‘;
- The topic ‘Widget commands’ is closed to new replies.