1) My Articles of all time

My Weekly Newsletter: 5 mins & 4 ideas I’m wrestling (free, you Scrooge)

function posts_by_month_shortcode( $atts ) {
global $wpdb;
$output = ”;
$months = $wpdb->get_results(“
SELECT DISTINCT MONTH(post_date) AS month, YEAR(post_date) AS year
FROM $wpdb->posts
WHERE post_status = ‘publish’ AND post_type = ‘post’
ORDER BY post_date DESC
“);
foreach ( $months as $month ) {
$output .= ‘

‘ . date( ‘F Y’, mktime( 0, 0, 0, $month->month, 1 ) ) . ‘

    ‘;
    $posts = new WP_Query(array(
    ‘year’ => $month->year,
    ‘monthnum’ => $month->month,
    ‘posts_per_page’ => -1,
    ));
    while ( $posts->have_posts() ) {
    $posts->the_post();
    $output .= ‘
  • ‘ . get_the_title() . ‘
  • ‘;
    }
    wp_reset_postdata();
    $output .= ‘

‘;
}
return $output;
}
add_shortcode( ‘posts_by_month’, ‘posts_by_month_shortcode’ );

Weekly Wonders Newsletter

4 ideas each week that’ve made my life happier & more enjoyable

138+ readers swindled (so far)