<?php
$today = getdate();
$args = array(
//'nopaging' => true,
'paged' => $paged,
'category' => 1,
'posts_per_page' => 36,
'date_query' => array(
array(
'after' => $today[ 'month' ] . ' 1st, ' . ($today[ 'year' ] - 2)
)
)
);
$catgory_posts = new WP_Query( $args ); // The Query ?>
<div id="grid">
<?php if( $catgory_posts->have_posts() ) while ( $catgory_posts->have_posts() ) : $catgory_posts->the_post(); // The Loop ?>
<?php get_template_part( 'article', 'thumb' ); ?>
<?php endwhile; ?>
</div>
<?php get_template_part( 'navigation' ); ?>
See date parameters at WordPress codex: http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters
Related Posts:
- Problem with my loops
- Some doubts about how the main query and the custom query works in this custom theme?
- WP_Query vs get_posts
- Order posts by ID in the given order
- Get the number of posts from the current page results
- Query Custom Meta Value with Increment
- How to query ‘posts_per_page’ to display a different blog posts index template?
- Date query not inclusive despite parameter being true
- Use meta_query to display events by date in custom field
- 2 loops on page – one with orderby rand second orderby date
- Query posts by specific word on title
- Five posts from a category in footer
- Multiple loops without repeating content
- WP_Query condition affects posts_per_page count
- How can I create ‘future’ and ‘past’ parameter for restAPI by filtering the CPT custom date field by greater than / less than current datetime?
- Some doubts about how the main query and the custom query works in this custom theme?
- How do I rewrite this loop as a new WP_Query style-loop?
- Include current post into loop
- How to provide meta_key array to wp_query?
- get_posts output always same post
- How to get posts published on the latest date?
- How to create custom query by keyword in post title?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- Ordering posts by custom field and grouped by month
- 2 queries with counters
- Show single posts date, in a page of posts
- Paginate pages with dynamic query
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- query hook parse_tax_query function takes no effect
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How do I stop the same post showing multiple times in a archive?
- Custom query for custom post type not getting correct post ID
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Ordering Posts by parent category, name ascending
- Converting an existing query_posts to WP_Query
- Query Posts by date range with fixed beginning and end
- Multiple loop for “featured” items returns wrong posts
- Show number of posts AND number on current page (cannot make it work)
- WP Query where title begins with a specific letter
- WP_Query: query posts by ids from array?
- pre_get_posts with get_posts
- Retrieving 3 latest post from each of 5 different custom post types
- Sort posts by custom taxonomy name
- List taxonomy terms plus their latest post ordered by post date
- Show default content if custom WP_Query has no posts
- Display one latest post from multiple categories
- meta_query on a date range using an array of values
- WP query exclude post within the last month / only show over 1 month old
- WordPress query for most recent posts from multiple categories
- Too many posts cause slow load when paginating
- Query post with meta_query where date is not in future
- Apply CSS class to every second database record [closed]
- How to prevent writing duplicate loops?
- Slow page loads due to WordPress Core Query
- 1/3 of posts different class
- 2 weeks ago from meta query meta value
- WP Group posts by year(desc) > month(desc) > date(asc)
- Running main loop 2 times with conditional statement
- Array as ‘key’ in WP_Query
- Reset WordPress Post Query to default
- Is_single() conditional tag returns null in query
- Posts in loop all show the same author when there are many authors
- If have posts a week old, display, else display a different loop
- Create a page template for “top rated posts” but show full content and not just a list
- Daily drip of posts – based on user ‘startData’ – ordered oldest to newest
- How to add tax_query to $args with concatenation
- Posts limit on homepage (genesis framework)
- WP_Query not returning correct result with meta_query parameter
- How do i create a custom post query when the meta value is an array?
- Query for current post
- Loop through array of pages
- Ajax buttons not working properly in WooCommerce when using wc_get_template_part
- How to show post title in content editor in backend?
- WP_Query doesn’t works inside loop
- Problem with custom WP_Query and underlying pagination/posts_per_page
- Pull posts from all categories if quantity is not met?
- Query_post 5 post first / last of post_id
- View related categories in order of posts
- 2 Loops on one page – pagination of 2nd loop ignore array of excluded posts
- Show posts in category
- Both WP_Query and get_posts returning 1 post
- Using WP_Query to re-query and sort results using a date?
- Custom post type archive organized by category
- wp_query display posts based on day
- No content found on page 2 of pagination with 1 post per page
- Adding a category at even positions on main loop with modified pagination
- Query Posts to fetch Posts with Unique Tag
- Get author meta data with no published posts in author.php?
- Print post data inside loop using theme content template
- WP_query shortcode inside acf Repeater breaks the repeater loop