You can use WP_Date_Query in conjunction with WP_Query to accomplish this.
$query = new \WP_Query( array(
'posts_per_page' => 5,
'date_query' => array(
array(
'day' => date( 'j', current_time( 'timestamp' ) ),
'month' => date( 'n', current_time( 'timestamp' ) ),
'before' => 'this year'
)
)
) );
if ( $query->have_posts() ) :
while ( $query->have_posts() ) : $query->the_post();
// Do stuff.
endwhile;
endif;
Related Posts:
- Show a different number of posts per page depending on context (e.g., homepage, search, archive)
- [Plugin: Posts 2 Posts] How does it work?
- Manually set global $post vars with an ID, in order to use template tags
- How to prevent a post from being deleted?
- How can I make it so the Add New Post page has Visibility set to Private by default?
- How to moderate posts
- Limit access to posts/pages by user roles
- Show Similar Post Titles ( Similar to Stack Exchange )
- How to add option box in “Edit Post” plugin API?
- How Do I Use The WordPress Plugin Posts 2 Posts by Scribu?
- How do I unlock a post programmatically?
- How to work with Syntax Highlighter Evolved?
- User-Specific Timezones? Hack? Plugin?
- Is their any way to Extend WPDB class and Overwrite the Default Query Function
- Delete Post With No Traffic?
- How to Add jQuery Infinite Scroll to My Custom Archive Page
- Automatically Creating Posts for Popular Forum Topics or Products [closed]
- Let readers suggest edits from the frontend
- Using nextGen Gallery.. how can I call a list of all Gallery Names?
- Search and replace text across all posts
- Can we completely remove the WordPress Sitemaps (WordPress 5.5)?
- jQuery plugin only in one page/post
- Disallow a user to post in certain categories
- How To Ignore a Filter On Applying Filter the Content In a Function
- Auto-post to multiple sites like Posterous? [closed]
- Article source link for posts
- publish_post hook isn’t working for scheduled posts
- How to get posts by content?
- Share buttons on article footer
- How to create a Page alias in WordPress
- Plugin for changing a post’s category based on it’s post date?
- Publish Post After Click On A Link
- bulk post_content update
- WP get_permalink Return Wrong URL
- How to extract images of post and pages excluding header and logo image in wordpress?
- Dynamic HTML not displaying at respective place
- Fastest way to loop through all posts?
- Get the last post ID
- Enable comments for post with comments meta box removed
- Edit/revise option for authors to suggest improvement to posts [closed]
- Is there a plugin to display certain posts on certain pages? [closed]
- Custom Post Type causes Page Not Found
- Unique post-id for WordPress Multisite Network
- Is there an action that is called when a post is restored from the trash?
- plugin for wp_list_categories with posts
- How to filter content post only on save
- post expire after x days
- Action on post publish
- Replace existing pages with new pages, keep menu links
- Adding “ ” before the last word in multiple defined areas with a plugin
- Set attached to state
- Use plugin or custom post type for game score functionality
- Tag link suggestion plugin
- How to add new tabs in post.php
- How to change ID of an attachment in wp_posts and its related tables correctly?
- Collaborative post submission [closed]
- CKEditor: Uncaught TypeError: switchEditors.switchto is not a functiononclick
- New post notification plugin [closed]
- Is there plugin to show recent posts from one website in the widget area of another?
- Bulk Image Uploader to create new post from each image [closed]
- How use %like% in sql statement wordpress
- Display comments of users on single page
- Get the url of the full sized attachment image using post ID?
- Adding Plugin-specific Fields with wp_insert_post()?
- Adding Attachment Display Settings in custom media frame
- Output HTML only on individual post view
- Using the “Latest posts” feature on a different site
- Is there a way to order posts and custom post types as one group?
- Execute a plugin only on post pages
- How can i list random post from multiple category?
- Support for simultaneous editing
- How to get 1 or 2 specific posts on top of my wordpress blog?
- Portfolio + Blog: multisite or plugin?
- Accessing post’s meta data based on user’s click of a post
- Plugin echos text from shortcode function in gutenberg page editor
- View Private Published Page with URL Code (no login required)
- With W3 Total Cache when I publish a post it does not appear in the homepage. Only if i purge all cache [closed]
- The problem with WordPress Importer
- Cron job not firing
- Solutions to repost categories into multisite blogs?
- How to enable qTranslate languages tabs in custom plugin page
- How do I “get the next 10 posts after post_id == x”?
- Hiding posts – WP Hide Post not working
- submit posts by unregistered users in wordpress
- Most visited posts
- Get a submitted value from front end post form for single template
- Using Postmash plugin in WordPress 3.3.1
- What is the correct method for updating post content from a plugin?
- Custom feed parameters / Template overriding
- Using wp config to connect to a DB from a plugin
- How to make only selected posts appear on a selected wordpress page
- Automatically set posts to NoIndex depending on category?
- Get post id in Post Page within Wp-admin
- wp_update_post does not change post status from draft to publish, returns 1
- Notification When Post Approved
- PHP $_session is not work in wordpress
- Embedding BitBucket Code in Posting
- Static page with formatted post list
- Next and Previous Pagination button not displaying in WordPress
- How to block external download link access if visitor not referred from WP?