-
KBParticipant
I am having posts that are in ‘Pending’ status showing up in the footers in the ‘most commented’ section because I have a program that imports my posts and comments from Google+.
How can I filter out posts that have not been published?
Thanks.
Daniel TaraKeymasterI have checked the theme’s function clearly selects only posts that are published, however it’s doing it in an old-fashioned way. Try opening the file functions.php and for the function
list_most_commented
change the line:$posts = $wpdb->get_results("SELECT comment_count,ID,post_title,post_status FROM $wpdb->posts WHERE post_status='publish' ORDER BY comment_count DESC LIMIT 0 , 6");
with:
$posts = get_posts( array( 'numberposts' => 6, 'orderby' => 'post_date' ) );
- This reply was modified 11 years, 11 months ago by Daniel Tara.
KBParticipantTHANKS!
This worked and got rid of the pending posts… but it doesn’t seem to be counting the posts right. It shows three that have a few comments on them but the one that has the most comments isn’t in the list.
Does this take some time for it to recalibrate or should I look at something?
Daniel TaraKeymasterSorry I made a type, here’s the correct code:
$posts = get_posts( array( 'numberposts' => 6, 'orderby' => 'comment_count' ) );
You must be logged in to reply to this topic.