These $args
is what you need and you may also use that in query_posts()
;
$args = array(
'post_type' => array( 'post' ),
'post_status' => 'publish',
'posts_per_page' => 9,
'cat' => $link1, // try better variable name
'meta_key' => 'post_views_count',
'orderby' => 'meta_value_num',
'order' => 'DESC',
'date_query' => array(
array(
'after' => '1 months ago',
),
)
);
$r = null;
$r = new WP_Query($args);
// do something with $r = result
wp_reset_postdata();
I provided you some other way than query_posts()
.
BTW, I like you used wp_reset_query();
at the end.
Related Posts:
- Is `query_posts` really slower than secondary query?
- Are there any scenarios where the query_posts may be used?
- Why is it necessary to call rewind_posts() when using the loop more than once? [duplicate]
- Multiple posts with one loop iteration
- Post Loop not Returning Permalink
- Sort Popular Posts by Views for the Last Week
- How to Loop within a Loop (Display Children and then Grandchildren)
- Exclude first 2 posts with meta_key from loop
- Better way to display posts from specific categories, in a grid layout
- 3 Posts in Loop, Show Stickies First
- Query last updated posts (posts updated in the last 24 hours)
- Displaying terms based on loop posts?
- Duplicated posts on category page
- Make blog page show 10 on first page, 9 on every other page
- How to display posts by vote count and if no value continue with latest posts with no votes?
- query_posts() vs get_posts() multiple loops [duplicate]
- Exclude first post (sticky or not) from the loop using query_posts()
- How to order by multiple fields using standard query_posts?
- Pagination not working in category listing [duplicate]
- How can I improve the performance of this query_posts loop?
- Adding div after every two post on main loop! Why will first post not get counted?
- How can I access specific posts brought back by query_posts?
- Separate First Post Loop
- Query posts only with actual text content (not including shortcode or images)
- query_posts clarification needed
- Exclude current post ID from loop in sidepbar.php
- Why does my WP_Query pagination on a custom page.php only loads the homepage?
- Get a Post Loop based on Logged in User information into a Shortcode
- how to add 4 post in one carousel slide
- Query counting excluded category on paged loop
- get_posts and wp_autop (remove filter)
- query_posts ignores the argument
- The Loop isn’t working
- Twitter bootstrap carousel multiple items in carousel
- show posts from one category with comments only
- Least Number of Loops to Create Custom Homepage?
- How to do query_posts on tags pages
- Limitless amount of posts in custom archive page
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- How to get Author ID outside the loop
- remove tags from the_content
- the_title() shows title of the first post instead of the page title?
- Why do themes rely on “The Loop”?
- Modify main WordPress loop with a parse_query filter
- Retrieving 3 latest post from each of 5 different custom post types
- Two custom loops, pagination, offset
- What exactly defines a Main Loop and a Secondary Loop?
- Loop code is displaying pages but not actual posts
- Access to Media Library
- Getting two wp_link_pages output
- post loop causes wp_users and wp_usermeta DB queries for each users
- Ajax loop refresh on click
- How to order results by date and meta key?
- the_excerpt(), get_the_excerpt() and the_content() all killing “the Loop”
- Is get_posts() more efficient than The Loop?
- loop through all posts memory error
- Display the_content on click jquery
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Missing image in gallery shortcode in custom feed
- Including post thumbnail url in loop’s post object to reduce number of queries
- Duplicate posts in paginated results
- Posts active and expired in different loops
- Pagination on Single Post
- Display Posts Only with Specific Tag
- How to get my loop to paginate?
- Get author Meta for particular user inside the loop
- Foreach displays from last to first
- value of metadata is null wrong use of if statement
- Count post views in loop
- displaying recent comments outside loop without plugin
- add offset to archive page
- Category ID returns as ‘0’?
- make get_post work in the loop
- How to display 3 post per slide
- For Each +1 WordPress Loop
- Custom Post type showing up in loop, regular posts are not showing up
- Skip 5 latest post while paging?
- WordPress: query pages except remove one page
- get_post_meta printing empty fields, but it shouldn’t be
- Is it possible to set archive.php instead of index.php to display blog?
- How to read taxonomy in loop?
- Undefined index: page in loop load ajax content
- Exclude Posts Using Meta Query and User Meta
- Is “the loop” a template tag?
- Deeply Nested Menu Loop with Twig using Timber [closed]
- WordPress with woocommerce custom query
- Get featured image outside the loop using foreach
- Page gets displayed in post field
- Active class for my flexslider in WordPress
- setup_postdata in “loop-handling” php file called via $.ajax
- Can’t see custom field after the Loop [closed]
- Same Loop on Multiple Pages
- single.php fires more than once after clicking on any post to view with different post id each time
- get all page templates
- query_posts and sub pages?
- strange parse error when including a loop template within another template
- Previous Posts Link and Next Posts Link Show All The Same Articles?
- Pagination in category.php not functioning
- Undefined variable: woocommerce_loop [closed]
- How to get files from loop for zip