My Weekly Newsletter: 5 mins & 4 ideas I’m wrestling (free, you Scrooge)
Below are letters to my younger self. They are my interpretations of the world.
“If I have seen further, it is by standing on the shoulders of giants”
Isaac Newton
- December 2024
- November 2024
- October 2024
- September 2024
- August 2024
- July 2024
- June 2024
- May 2024
- April 2024
- March 2024
- February 2024
- January 2024
- December 2023
- November 2023
- October 2023
- September 2023
- August 2023
- July 2023
- June 2023
- May 2023
- April 2023
- March 2023
- February 2023
- January 2023
- December 2022
- November 2022
- October 2022
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 ) ) . ‘
- ‘;
- ‘ . get_the_title() . ‘
$posts = new WP_Query(array(
‘year’ => $month->year,
‘monthnum’ => $month->month,
‘posts_per_page’ => -1,
));
while ( $posts->have_posts() ) {
$posts->the_post();
$output .= ‘
‘;
}
wp_reset_postdata();
$output .= ‘
‘;
}
return $output;
}
add_shortcode( ‘posts_by_month’, ‘posts_by_month_shortcode’ );