Limit characters in popular posts results
-
The theme I’m using has a function to display a list of four posts that are the most popular, deemed by the number of comments they have. I’d like to limit the characters in the popular post results. Here’s the code:
<?php $sql='SELECT post_title, comment_count, guid FROM wp_posts ORDER BY comment_count DESC LIMIT 4;'; $results = $wpdb->get_results($sql); foreach ($results as $r) { echo '<li><a href="' . $r->guid . '" title="' . $r->post_title . '"> ' . $r->post_title . ' (' . $r->comment_count . ')</a></li>'; } ?>
Any help is greatly appreciated. Thanks is advance!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Limit characters in popular posts results’ is closed to new replies.