• Resolved thisisedie

    (@thisisedie)


    I want to get the post count for a certain year. I’ve tried doing different things with this code

    <?php
    $count_posts = wp_count_posts();
    echo $count_posts->publish;
    ?>

    but none work. Can anyone tell me how I can do this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Could use wpdb on the wp_posts table but this seems easier:

    <?php
    $count=0;
    $my_query = new WP_Query('year=2008');
    while ($my_query->have_posts()) : $my_query->the_post();
    $count++;
    endwhile;
    echo '2008 post count is ' . $count;
    ?>
    Thread Starter thisisedie

    (@thisisedie)

    Thanks muchly ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Post Count For Certain Year’ is closed to new replies.