• Hi there,

    I noticed that when I list my authors with this tage:

    ‘<?php wp_list_authors(‘optioncount=1&show_fullname=1&hide_empty=1′); ?>’

    That it also shows the authors draft posts.

    How do I fix this?

    Thanks

Viewing 1 replies (of 1 total)
  • Hi there

    Try to change this function in functions.php (in the include-directory):

    function get_usernumposts($userid) {
    global $wpdb;
    return $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = ‘$userid'”);
    }

    to something like this: (this will count the number of published posts)

    function get_usernumposts($userid) {
    global $wpdb;
    return $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = ‘$userid’ AND post_status = ‘publish'”);
    }

    or (to just count each non-draft post):

    function get_usernumposts($userid) {
    global $wpdb;
    return $wpdb->get_var(“SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = ‘$userid’ AND post_status <> ‘draft'”);
    }

Viewing 1 replies (of 1 total)
  • The topic ‘Draft posts showing up in wp-list authors’ is closed to new replies.