“Popular Posts” script that returns permalinks
-
Hi all,
Was wondering if any code gurus out there could help me tweak a bit of script I have been using. It is a script I include in my footer as a way to show “popular posts”.
My problem is that it displays results with the ‘ugly’ guid links. The p= kind. I would like it to return and display links using my permalinks.
Any thoughts?
Here is the code:
<?php $sql='SELECT post_title, comment_count, guid FROM wp_posts WHERE post_status = "publish" ORDER BY comment_count DESC LIMIT 6;'; $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>'; } ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘“Popular Posts” script that returns permalinks’ is closed to new replies.