It’s hard to say exactly why adding the category changes anything, but… The query looks OK… Almost… There are some things that concerns me:
'post_type' => 'posts',– there is no built-in post type calledposts. You should usepostin there, unless it’s your CPT (but then… I don’t think it’s a good name ;))
This is the biggest concern. But there are some minor ones also:
'posts_per_page' => '4',– it should be a number, it will be converted, but why should it have to…'nopaging' => false,– it’s default value for this arg, so there is no point of setting it.
Related Posts:
- The next_posts_link() works only with original $wp_query
- Adding additional data to WP_Post object
- WP_Query: Why is sticky post not first item in loop?
- Query *only* sticky posts
- Skipping first 3 posts in wp query
- Most viewed post for the last 2 days using WP_Query
- Adding Post Counts to Menu (Nav) Programmatically?
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Get only modified posts
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- Hide Post comments when displayed via WP_Query
- posts_per_page doesnt work
- wp query with dynamic taxonomies and terms?
- Blogroll – Different layout for first post
- How do I use `posts_distinct` correctly?
- Automatic value for custom fields for posts
- Loop through all product posts?
- Improving WP_Query for performance when random posts are ordered
- Why won’t my taxonomy query show up?
- How to find what index page a post is on?
- Get Posts that are in the current month or later
- WP Query to Get Array of Slugs
- WP_Query with ajax handler returns the same posts
- Why WP_Query(‘showposts=5’) shows only 1 post?
- How can I sort posts by the date and a custom meta field?
- Hiding Draft Post In Admin
- How to insert 2 args into 1 Wp_Query for a slideshow
- How to verify wp user password by sql query in wp? [closed]
- WP Query – Posts Per Page not working in combination with category__in
- Lost draft under all posts and drafts
- Get user categories with most posts in it
- Query Posts With Over 1000 Views
- List authors with the last post title and order by last post date
- How to order posts by meta_value and title
- Adding a blog archive with pagination using WP_Query
- How to get Tags with specific post id
- WordPress query_posts by tag doesn’t work anymore(?)
- Ignore latest two posts
- Show posts by author of membership level (Paid Membership Pro)
- Print out last 3 blogposts
- How to get posts published on the latest date?
- Why posts array is empty?
- How to group only VISIBLE posts? [closed]
- How to check in functions.php if there is data in a WP_Query?
- Shortcode with ‘year’ parameter
- On what hook can I get the queried object’s final state?
- How can I insert a new markup element after 4 posts automatically? [closed]
- If no posts exist for current day and month, show the next available day of posts
- how to handle the loop using filling bootstrap grid structure?
- Get all custom posts with a certain taxonomy
- Link to date_query results in WordPress
- Query function not executed between element [closed]
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- Limiting post list by taxonomy
- How to display WP Query filters?
- Finding a post’s slug
- Is there a function to get post info for any publish_status by post ID?
- How Can I Always Display A Particular Post First Using WP_Query?
- Optimal WP Web App Backend for mobile app development
- How do I display main query posts in random order using add_filter
- Why sorting posts doesn’t work properly?
- the wp_post_update isn’t working all the time
- Function is printing twice – any suggestions?
- query posts with selected post ids first
- Change URL of previous posts and next posts link in WordPress
- Order posts inside bootstrap card columns
- How to use two query result together in one loop
- show loop id post , only first id can read
- How to get value of a selected option from select tag and use it in WP_query to filter posts?
- Counting Posts by Category
- Fill the exclude array() in get_posts()
- show image gallery in archives or category page
- Page with Category Returning 1
- The first post appears twice
- wp_query args with relation
- WP_Query sort by meta_value_num or date
- Get 5 most recent categories
- Creating Ordered Query using Meta_key
- Custom layout manager for posts
- WP Query between posts custom fields [duplicate]
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Retrieve latest post by multiple categories with ID
- Update Post with Modified Data
- Can’t get pagination to work
- How to Include a common category in a custom Category Search
- wp_query select if have comments
- How to get single post by one author?
- wp_query posts sorting doesn’t work
- Order by ‘s’ using WP_Query()
- custom sort posts in archive/taxanomy page
- how to print loops for odd in 1st column and even in 2nd column in wordpress [closed]
- List posts related to category on a div [closed]
- Trying to create shortcode listing custom posts, but formating not being included
- Show Title/Date/Excerpt of first post & only Title for rest in Query [duplicate]
- Get posts after calculating meta key
- Next and Previous buttons are not showing on home page for post
- How edit footer copyright info? [closed]
- Filters do not work when there are multiple (one works)
- date_query returning only the most recent post instead of the post published before today
- How to make WP_Query faster when getting a post from one year ago?