one possibility is to run all posts through the loop and only output the month once per new month:
<?php
$counter = 0;
$ref_month="";
$monthly = new WP_Query(array('posts_per_page' => -1));
if( $monthly->have_posts() ) : while( $monthly->have_posts() ) : $monthly->the_post();
if( get_the_date('mY') != $ref_month ) {
if( $ref_month ) echo "\n".'</ul>';
echo "\n".'<h6>'.get_the_date('F').'</h6>';
echo "\n".'<ul>';
$ref_month = get_the_date('mY');
$counter = 0;
}
if( $counter++ < 5 ) echo "\n".' <li><a href="https://wordpress.stackexchange.com/questions/58078/.get_permalink($post->ID).">'.get_the_title($post->ID).'</a></li>';
endwhile;
echo "\n".'</ul>';
endif;
?>
Related Posts:
- Difference between an archive and a page listing posts
- has_archive=false on the default post type
- Clear cache when a post is submitted [closed]
- Create an “All Posts” or “Archives” Page with WordPress 3.0?
- Post Format Archive template name for theme folder?
- widget should display post archive by year and on click also by month
- Must permalinks always point to single post pages?
- At my posts archive page, outside the loop, get_the_id() returns the top most post’s ID
- Display most recent post in category instead of archive?
- Single.php Active Category Class
- Link for the page archive for posts, like using custom post types with get_post_type_archive_link
- get_post_type_archive_link(‘post’) returns current category archive
- How to get the latest posting time of archived pages in WordPress?
- change default post archive page link
- Display posts from #6 to #20 on archive page
- Category List (Archive) Page Template By Category
- Getting category posts from a certain year
- Yearly archive page for future year
- Which URL to enter into browser to show all posts in archive.php?
- How to display data in archive page?
- Guest Author – How to display posts on /author/ archive page
- Archiving by academic year instead of calendar year
- List category posts alphabetically on archive.php
- How to display excerpt post on hamepage and archive pages?
- Increase 10 post limit per page
- Automatically create a new page daily with last three posts
- Archiving posts in wordpress
- Custom Post Type archive
- Does WP automatically tag posts into the archive?
- singular posts using archive styling
- I want to show my post for limited time, how is it possible?
- Exclude a category of posts in author template
- How to edit the ‘
- Post-Archive like a page in a specific subdirectory
- Display in category ( taxonomy) a number of post that I want
- Find out in which kind of archive am I
- adding my posts (author posts) in menu
- How to view all posts (on site, not admin) that are uncategorized?
- Archieve page, Advertisement Every 3 Posts
- Highlighting Current Category in the Archive and Feeds page
- Permalink Short code showing unnecessary link text inside the loop
- How to hide protected posts from archive?
- blog post not accesible on click [closed]
- Redirect to custom post if custom archive page has just one result?
- Posts are not displaying on their category and tag page
- show image gallery in archives or category page
- Prevent Archive URLs
- view a list of 3 future post, from the nearest to the most far
- Get posts from category from custom query
- How do I apply a wordpress function to something with no ID inside an archive page?
- Page 2 has no posts?
- Disable archiving of old posts?
- is_archive() not working on selected “Posts page”
- How to display term in archive page?
- My posts section for logged in user
- How to organise post by category and date
- Daily posts like an archive
- How to set a link to custom archieve page
- How to get alphabetic listing x other posts, based on first letter post?
- How do I display the next 3 posts in the sidebar?
- Display all posts from selected month
- How to get pagination working with “Pending” Posts
- Show all posts in category
- custom sort posts in archive/taxanomy page
- how to show all post with its contents
- Add author section on Author archive posts
- Display post count on archive page in reverse order
- Filter/Sort Post Form On Taxonomy page
- Global $post value outside the loop
- Category and archive issue
- Display posts on a custom page from only a specific category?
- Display post archive as a month table, show last three months
- Replacing all attachment links in post with media file link
- Post content being duplicated by the_content();
- Custom Post Templates
- Exclude newest post from category X but show rest
- post-page: reference to parent page?
- post categories
- Move first half of posts to one parent page, second half to the other page
- Can I search posts and pages for css classes?
- Find the Post ID of a post from another website
- Disable auto-save and post revisions from inside a theme or plugin
- Migrate posts from category and sub-category via SQL
- How to get post with slug and exclude categories
- How can I set a maximum allowed post size and number of posts submitted?
- Adding post date will not insert new post
- Only show featured image on exerpt and exclude images in post
- Prevent 404 of Author pages without posts
- Categories Listing and Highlighting current category item
- WP_Query get posts in custom database table [duplicate]
- How to save template data into wp_post table (post_content column)
- How to set a Post’s default visibility to ‘Private’ in Gutenberg?
- Sticky Post Doesn’t always work
- Add post id as body class in wordpress admin dashboard [duplicate]
- Blog posts not displaying on blog posts page
- Multiple Custom Post Type loop logic
- WP_Query retrieve custom posts but not the post showing
- How to handle dates, trying to calculate time since a post
- How to Post to Specific Pages?
- Allow User Can See His Post on his dashboard