[resolved] Query doesn't returns expected values (1 post)

  1. J_25
    Posted 7 years ago #

    I have the following function that's supposed to return a list of posts that have a comment count grater than 1 let's say. I want to use this function to display a list of hot post.
    The problem is that it doesn't outputs anything...why? I run the query in MySqlYOG and the query works just fine...

    function custom_GetHotTopics( $limit=10 )
    	global $wpdb;
    	$sql = "SELECT ID, post_title FROM wp_posts
    			WHERE post_status='publish' AND post_type='post'
    			HAVING comment_count > 1
    			ORDER BY comment_count DESC LIMIT ".$limit;
    	$results = $wpdb->get_results($sql);
    	$output = '';
    	foreach ($results as $result)
    		$title = strip_tags($result->post_title);
    		$output .= '<li><a href="index.php?p='.$result->ID.'">'.$title.'</a></li>';
    	echo $output;

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.