• Resolved Fredriks

    (@fredriks)


    Hello,

    I wonder how I can count how many months there is where there are posts in?

    Example
    august 2010
    november 2010

    Above example should return 2.

    Is there any code or function I can use to get this?

    Thanks in advantage
    Greetings Fredrik

Viewing 2 replies - 1 through 2 (of 2 total)
  • This should do it:

    $list = wp_get_archives(array('type' => 'monthly','echo' => false));
    $months = explode('<li>',$list);
    array_shift($months);  // first entry is empty
    echo "<p>Count:" . sizeof($months) . '</p>';
    Thread Starter Fredriks

    (@fredriks)

    That works perfect vtxyzzy!

    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Count months in archive’ is closed to new replies.