getTopPosts

The ColorWay Theme getTopPosts function.

Description

getTopPosts(); 

Usage

  1. if ( !function_exists( 'getTopPosts' ) ) { 
  2. require_once '/functions/tabs.php'; 
  3.  
  4.  
  5. // NOTICE! Understand what this does before running. 
  6. $result = getTopPosts(); 
  7.  

Defined (1)

The function is defined in the following location(s).

/functions/tabs.php  
  1. function getTopPosts() 
  2. global $wpdb; 
  3. $request = "SELECT ID, post_title, comment_count FROM $wpdb->posts WHERE comment_count > 0 AND post_status = 'publish' order by comment_count desc LIMIT 0, 7"; 
  4. $posts = $wpdb->get_results($request); 
  5. $output = ""; 
  6. foreach ($posts as $post) { 
  7. $output.="<li><a href='" . get_permalink($post->ID) . "'>" . trimText($post->post_title, 35) . " <span class='gray'>($post->comment_count)</span></a></li>"; 
  8. echo $output;