If you want your posts based on different categories you should use category_name or cat as category id. For example;
<?php $test = new WP_Query('cat=1&showposts=1'); // where 1 is the id of your cat ?>
Or
<?php $test = new WP_Query('category_name=errands&showposts=1'); ?>
Also, you need to call wp_reset_postdata(); after each WP_Query. I hope this helps
More on how to use categories in WP_Query
Related Posts:
- Inject post (from specific category) between posts in Loop
- Count number of published posts by type
- Get taxonomy terms only of the WP_Query current posts
- Hide post if matches current month and year
- How can I use wp_query to show all product data using just the products ID?
- How to store post ID’s in cookie or session to display the same posts later
- WP_Query: getting posts where custom field exists
- Array to string conversion on array_map
- Store metakey value as an array
- Increment paged on WP_Query
- Modify main query before it run without pre_get_post
- Do not duplicate posts with multiple categories in multiple loops
- array_rand not working correctly?
- WP_Query() load selected post
- Wp Query : Order by distance lat,lon
- WordPress sorting posts by date and title using a dropdown
- posts_per_page displays only 2 posts instead of 4 posts
- Query on a repeater date (acf)
- Need to show 7 posts from actual date
- Check the database for a postmeta field
- Getting info about selected posts using one WP_Query
- How to display last whole post on the homepage
- Only Get A Certain Number of Posts From WP_Query
- insert thumbnail image from php script
- Weird Behaviour: Not all WordPress Posts appearing
- List of child pages fetch next results at link click
- Query category-specific, paginated posts and allow viewer to change sort order
- How to modify this function to exclude also the post belonging to a specific category?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- get_the_content if it contains multiple lines it results in SyntaxError
- Looking to exclude blog posts from category Previous/Next buttons
- Automatic Excerpt Not Working
- Using a javascript file to access a get posts array
- WP_Query with the “offset” argument
- Display Post co-authored in Author Page
- Sorting Posts | Alphabetical Order
- Looking for most performant way to execute several similar WP queries within shortcodes
- Trying to make php run in a post
- Remove posts after a given amount of time
- Hide wordpress field if data is empty in post!
- How to use an associative array in post__in with WP_Query?
- How to show part of the_content?
- How to set a min number of words for a blog post
- Get post id in a function when edit/add a post
- WordPress, AJAX and pre_get_posts using conditional tags
- Exclude posts based on meta value
- Loading index.php contents which located outside blog folder for post single page
- get post content of particular post by url
- Remove echo from shortcode
- How Can I use WP_Query to Only Display 1 Post from Custom Post Type if Query Returns Posts with Matching ID in Custom Field
- wp_query get the 2nd post
- Count posts on multisite with blog id
- Making (and edit existing) posts with ID included
- Parsing Menu Items and Blog Posts
- How to add div blocks after certain set of post
- How to show an entire post content and not also the excerpt?
- Hide posts if user is added to it WP_query
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Order BY Most Liked And Published Between Previous Week Monday And Next Week Monday
- .html end of URl affected to SEO?
- Sort posts in a specific way
- Update if post with specific title exists
- posts_nav_link pulling in multiple post types
- Free search and custom taxonomy query not providing the same result
- How do I reset $wp_query in a function?
- Replace a single variable with add_filter
- Sending simple variable on single page to WP JSON
- My Custom Post Type AJAX Query is Returning no posts – why?
- How to exclude meta no index pages from wp_list_pages
- meta_query search names when they have middle initials
- Don’t update modified post date when user add a product review or comment?
- Limit the number of characters/words in an excerpt for a related posts section
- get_filtered_term_product_counts – Get product terms if any products
- List all ACF field values across every post on one page
- Closing Comments conditionally in comments.php
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- Having trouble with customizing blog posts on the home page
- Related Posts: if there is no category use tags
- How do if all posts has this category ID then do this
- Getting error in sql query
- Querying posts from wordpress with 2 or more conditionals
- Insert div after every three posts in home.php [duplicate]
- PHP tag in post content makes wordpress go crazy
- SQL Query Search page
- Unable to get Post Category Name and URL
- Display Year and Month from custom field + Age Calculator
- Masonry layout within the loop
- How can I add WordPress Audio Player as featured audio in Audio Blog Posts?
- How to customize posts in WordPress by using HTML and CSS?
- wp_query on search results page showing all results every time
- foreach all the post
- Blog Posts not sorted and pagination not adjusted after filtering some category
- WooCommerce: write featured image dimensions to custom fields in product’
- Variable ++ in query loop
- a problem in class in class-wp-hook.php
- Count custom posts type and filter by tag
- transition_post_status hook, works – but not if the post is new
- AJAX WP_Query’s order and orderby parameters not working
- Exclude first post from wp query
- Warning: Undefined variable $post_id