How about making an array of months and then getting the posts per-month? Though I suspect this is somewhat less efficient than @Jared’s…
function get_posts_grouped_by_month( $year = null ) {
if ( $year == null ) {
$year = date('Y');
}
$months = range(1,12);
$posts = array();
foreach ( $months as $month ) {
$posts_for_month = get_posts(array(
'year' => $year,
'monthnum' => $month ));
$posts[$month] = $posts_for_month;
}
return $posts;
}
then, in the template:
<?php $monthly_posts = get_posts_grouped_by_month(2011); ?>
<?php foreach ( $monthly_posts as $month => $posts ) {
echo "<ul><strong>" . $month . "</strong>\n";
foreach ( $posts as $post ) {
echo "<li>" . get_permalink($post->ID) . "</li>";
}
echo "</ul>";
} ?>
Related Posts:
- The the_post_thumbnail without srcset?
- after_setup_theme always runs
- WordPress API Menu/Submenu Order
- How to move page template files like page-{slug}.php to a sub-directory?
- Add custom classes to anchor in wp_nav_menu
- What WP folder can I use to write files to?
- Are the WordPress Core CSS styles really all nessesary?
- Why I can’t add a CSS style in this WordPress theme?
- register_sidebar ignores ‘id’ and ‘class’
- Display a different theme for not logged-in users
- Best practice (forward compatibility) for theme options
- Add colors to existing color palette without replacing it
- Single Page WordPress Theme – Using page templates
- How do I get gallery thumbnail URL and change the default thumbnail size?
- Select menu on browser resize
- Returning Variables back into a template
- new theme permissions don’t allow me to edit
- Upgrading a custom theme through the Dashboard
- Which theme foundry has clean coded themes, where code is poetry [closed]
- What page should I use for a contact form?
- Retrieve data using wpdb to use for customizer controls
- How can a Theme Contain no Header File or Footer File?
- Cannot get full thumbnail size using the_post_thumbnail
- Is there a way to activate different theme for specified users? [closed]
- how can I remove the sidebar from my wp homepage [closed]
- Some translations do not work in my template class
- WordPress not registering Theme Customization Section
- How to remove a file included in parent theme with locate_template() via child theme?
- qTranslate with my own theme and settings
- Stylesheet not linking
- How to control layout of posts on page?
- Override template file i subfolders
- Theme Development for WordPress Multisite Installation
- How to add infinite scroll?
- get_option in header.php not returning value from customizer
- Include Parent functions.php in Child Theme functions.php
- create category on theme setup
- Why is it needed to enqueue parent stylesheet in child theme?
- WordPress Unite Theme: Footer isn’t sticking [closed]
- WordPress get_template_part() function not working
- Is accessing theme and using customizer GPL distribution?
- Where am I doing wrong in my theme menu?
- How can my theme allow users to take advantage of advanced html tags in posts
- How to enqueue javascript for WP Customize options sidebar?
- WordPress 500 Internal server error when activating custom theme [closed]
- Call to undefined function add_menu_page() on theme activation
- Best way to develop a new theme on a live site, with new content? [closed]
- How do I make the most minimal vanilla theme possible with nothing but raw content?
- Can I Set Up Session in WordPress Custom Page
- Is it acceptable for a WordPress theme to not accept widgets?
- Should all references to a text domain be to my current theme?
- How can I hard code my sidebar?
- Simple child theme modification but links are broken
- Making a WordPress theme based on twentyten
- theme style is applied on the dhasboard rather than the website
- Alignment Problem [closed]
- What $handle does WordPress use for a theme’s implicit style.css?
- Issue when posting updates/changes to wordress
- StoreFront WordPress theme: How can i create a new Home page with Custom design same as template [closed]
- A post with a clear:both in its css destroy the theme design, and the sidebar is moved to the bottom
- Unwanted empty line at the beginning of document
- Why is my container argument not working for wp_nav_menu() [closed]
- best practices for updating wordpress theme
- How to hide custom sidebar on mobile
- help needed for suit designing tool
- How to modify theme content in Thematic?
- How to update mark-up of a gallery block in a custom theme?
- Host Private Custom Theme
- My wordpress theme name isn’t updating straight away
- Customizer API Multi Sections in single Panel
- WordPress theme options checkbox default checked state
- Copying a modified theme from one wordpress site to another wordpress site [closed]
- How can I change this SVG shape that’s generated?
- Adding a second logo next to the main one in header
- How can I not disable my theme when I want to upload a new version of it?
- (Parent) theme Is Not Showing In Theme Selection Panel and Therefore Breaks Child Theme
- Is hand coding required at all?
- How to show some of category in wordpress
- using themename_the_custom_logo() in template-tags?
- Avoiding do_shortcode() loops
- Creating a theme just to deploy a single page
- Creating a Sub Category Template
- Custom page template not showing on page creation
- how can I re-utilize and class on a child theme
- Weird ‘theme update’ error [duplicate]
- How to figure out which wordpress theme a site was using?
- Incorrect search results in search.php – issue triggered by using `define(‘BodyID’, ‘search’); the_post();` in search.php
- Flexslider not working for my custom theme WordPress
- WordPress two sidebar layout or theme
- How to close open divs in post loop
- Standard Way To Do Custom Work Within A Page?
- Add Dynamic Sidebar to Exisiting WordPress Theme [closed]
- How can I install my custom-made theme on a wordpress.com blog? [closed]
- Turning WordPress Into full-featured website?
- Why am I getting posts back when I shouldnt
- Custom Single Page Portfolio Theme [closed]
- Full site editing templates folder vs block-templates
- Is child-theme required when modyfing “Appearence > Editor”?
- Export WordPress theme with modifications for other site
- how to combine wordpress and front framework