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?
- How Do I Use The WordPress Plugin Posts 2 Posts by Scribu?
- How to Add jQuery Infinite Scroll to My Custom Archive Page
- Search and replace text across all posts
- publish_post hook isn’t working for scheduled posts
- Plugin for changing a post’s category based on it’s post date?
- Publish Post After Click On A Link
- bulk post_content update
- Enable comments for post with comments meta box removed
- Edit/revise option for authors to suggest improvement to posts [closed]
- Is there an action that is called when a post is restored from the trash?
- plugin for wp_list_categories with posts
- 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
- How to add new tabs in post.php
- How to change ID of an attachment in wp_posts and its related tables correctly?
- New post notification plugin [closed]
- Display comments of users on single page
- Adding Plugin-specific Fields with wp_insert_post()?
- Using the “Latest posts” feature on a different site
- Is there a way to order posts and custom post types as one group?
- How can i list random post from multiple category?
- Support for simultaneous editing
- 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)
- Solutions to repost categories into multisite blogs?
- Is there an easy way to flag posts in the admin area?
- finding whether request is for post, and post id
- Display post lists in 2nd paragraph
- Preg Match All doesn’t Allow echo first character for WordPress Taxonomy Tags
- How to allow an editor to edit all WordPress blog posts but have the last say as administrator?
- Trying to fix form resubmition with PRG (Getting error: Cannot modify header information – headers already sent by)
- Display wordpress post’s in popup?
- WordPress and a secondary database?
- Unable to add TAB character to post?
- how to add text to posts from tags
- plugin code is pulling information from database in one instance and not in other. What is wrong?
- How to get the first post and second post in a wordpress blog?
- ‘Organize Series Plugin’ as muti author feature
- How do I publish portfolio items with a future date?
- Taxonomy Drill-Down / Plugin Help – hierarchical queries within plugin?
- Is there a way to make the main page only display a brief description of the full article?
- WordPress plugin Post Creation [closed]
- posts from multiple post types in one slider
- How to display the featured post on the category page?
- Flickering sidebar when scrolling page [closed]
- Where Should i write the code for wordpress ajax voting?
- how to execute some code after a post is published in WordPress [duplicate]
- How to return the values from a row where a value occurs for the first time among the rows available?
- trigger email when post is published by someone a user follows
- WP::is_main_query() Not Working
- Embed PDF into wordpress
- Hook Scripts and Styles in WordPress
- WordPress plugin: Getting posts where checkbox selected
- How to auto strip hyperlinks & images in wordpress post
- WP Editor, save content and category on frontend
- Plugin for TinyMCE to create reference to other posts
- How to get Recent Post From Each Category with Thumbnail?
- help intercepting save_post through plugin
- Why the internal link get converted into a comment?
- Copy/paste local images not working in WordPress
- How to change my 3000 Published post status to Draft using PHPMyAdmin
- Displaying different content depending on variable
- .com creates automated link in post
- Is it possible to customize a wordpress post from outside dashboard(Something like site.com/post-type/post/?e=post_id)?
- How to echo a PHP Code After the Content
- All Post WordPress Page Error
- Is it possible to create duplicate post on other site (either push, on publish, or pull, periodically)?
- WordPress CPT Url metabox collection
- Add dynamic color to each category item
- Is there any hook to change media html in post? [duplicate]
- Having trouble going from Jfiddle to implementing in WordPress :(
- Publish Post but don’t call publish hook in foreground post creation
- Better code/text editing for posts and pages?
- WordPress list child pages of custom post type
- Style WordPress Custom Post Type Single Page
- SWF in wordpress post
- get post excerpt by query
- Posts are deleted everyday at night
- Using Postmash plugin in WordPress 3.3.1
- What is the correct method for updating post content from a plugin?
- Using wp config to connect to a DB from a plugin
- Get post id in Post Page within Wp-admin
- PHP $_session is not work in wordpress
- Embedding BitBucket Code in Posting
- Next and Previous Pagination button not displaying in WordPress
- Notifications on WordPress Website [closed]
- Sell “create a post”, paid account for post creation
- Shortcode returning specific content of a post
- Looking for membership style plugin with edit option [closed]
- Change from blogger to wordpress
- How to customized post slider layout in elementor wordpress [closed]
- How to export post tags from wordpress
- Show WooCommerce products based on query parameters on redirect
- Getting 400 Error in wordpress website