WordPress.org

Ready to get started?Download WordPress

Forums

Count post hack (1 post)

  1. Ardnas
    Member
    Posted 12 months ago #

    Hello,

    I have just made the update 3.6 of WordPress and since my "hack" do not work any more.

    The hack allows to post(show) on the site the number of published articles, in wait(expectation) of edition(publishing) and the articles in the basket.

    Here is the hack which I use in my theme:

    In the file " functions.php "

    <?php
    //les sites valides
    function post_count_publish(){
    global $wpdb;
    $post_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish'"));
    return $post_count;
    }
    ?>
    
    <?php
    //les sites en attente
    function post_count_pending(){
    global $wpdb;
    $post_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'pending'"));
    return $post_count;
    }
    ?>
    
    <?php
    //les sites dans la corbeille
    function post_count_draft(){
    global $wpdb;
    $post_count = $wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'draft'"));
    return $post_count;
    }
    ?>

    In the file " footer.php "

    <b>Statistiques :</b>
    <br /><?php if(function_exists(post_count_publish)) echo post_count_publish(); ?> Sites valides
    <br /><?php if(function_exists(post_count_pending)) echo post_count_pending(); ?> Sites en attente de validations
    <br /><?php if(function_exists(post_count_draft)) echo post_count_draft(); ?> Sites dans la corbeille

    Here is the error message which displays in the screen:

    Statistiques :
    Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/rankannu/wp-content/themes/arras-classical-gamer/functions.php on line 5 and defined in /public_html/rankannu/wp-includes/wp-db.php on line 992 2 Sites valides
    Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/rankannu/wp-content/themes/arras-classical-gamer/functions.php on line 14 and defined in /public_html/rankannu/wp-includes/wp-db.php on line 992 0 Sites en attente de validations
    Warning: Missing argument 2 for wpdb::prepare(), called in /public_html/rankannu/wp-content/themes/arras-classical-gamer/functions.php on line 23 and defined in /public_html/rankannu/wp-includes/wp-db.php on line 992 0 Sites dans la corbeille

    Have you an idea on the problem?

    Thank you very much for your help(assistant)

    Saddened for the translation my English are null.

    Sandra

Reply

You must log in to post.

About this Topic