Filter posts showing in Footer

Viewing 4 posts - 1 through 4 (of 4 total)
  • #5065
    KB
    Participant

    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.

    #5088
    Daniel Tara
    Keymaster

    I 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 12 years, 6 months ago by Daniel Tara.
    #5437
    KB
    Participant

    THANKS!

    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?

    #5471
    Daniel Tara
    Keymaster

    Sorry I made a type, here’s the correct code:

    $posts = get_posts( array(
    	'numberposts'     => 6,
    	'orderby'         => 'comment_count'
    ) );
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.