You don’t need to loop over each category & query them one-by-one, just query them all once:
$query = new WP_Query(
array(
'post_type' => array( 'service' ),
'category__in' => $ucategory,
'posts_per_page' => -1,
)
);
Related Posts:
- How to exclude latest x posts from a paginated query?
- Query posts distinct authors
- How to get previous 10 days post from a specific date – WP Query
- Hiding posts in a list from specified categories
- How would I get 1 latest post from a query for 5 posts?
- Exclude posts with empty post_content in wp_query
- Improving WP_Query for performance when random posts are ordered
- Reset Popular post query?
- Why WP_Query(‘showposts=5’) shows only 1 post?
- is there a way to show the the post title after the image?
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- Random ajax load only works with posts_per_page set to -1
- Multi row post list
- posts_per_page option limits the number of Gallery items
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- why the same code got different results when using query_posts in functions.php and index.php
- Query for first 3 posts to change the look and feel
- How to get posts published on the latest date?
- 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?
- wp_query with ajax
- How to give classname to post if post has no content?
- WP_Query: Show 10 posts in date order, first three random
- Random posts that always include a particular post?
- WordPress post filter menu
- Query function not executed between element [closed]
- Echo the number of posts being displayed
- WordPress query portfolio posts
- Display 3 posts with different HTML markup using a loop
- Change content off every sixth element
- Show posts from two specific category in WP_Query
- How to create loop of posts except post ID defined via ACF field
- Displaying all posts from other sites on the network on one site
- Multisite how to display merged posts from two sites and sort by latest date?
- Show 5 posts and than 3 posts offset with pagination
- wp_query args with relation
- Manipulate query to show specific post
- Sort / Filter Queries
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- How do I control the fallback query after the original query returned cero posts?
- Adding a category at even positions on main loop with modified pagination
- wp_query select if have comments
- query_posts different amount of posts per page [duplicate]
- Should we trust the post globals?
- Querying post from a multisite network
- How to know if get_posts() failed?
- Show related posts by category but ignore one category
- post__in for get_posts with a dynamic array
- Post content being duplicated by the_content();
- Only display posts with comments
- How to add padding between posts
- Working Bootstrap Carousel Conversion to WP – Technical Questions
- Add few specific post ids to wp_query
- WP_Query posts_per_page ignored
- Can I set and show “important” post in my blog?
- wp_query ‘s’ parameter does not work with custom post type
- WP Query – duplicated posts once including tags in search results
- previewing my posts on static page?
- how to get posts ids inside pre_get_posts filter?
- recent posts for different categories
- Category Foreach keeps looping?
- Change post order random through out the entire WordPress
- Anyway to grab author name and featured image in an embeded in inital array of posts outside of loop?
- Removing noindex posts from wp_query
- Exclude the first ‘n’ number of posts of a tag from home page?
- Using wp_list_pages() after calling query_posts()
- Why are my paginated posts always returning the same results?
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Query posts by Author and/or by Tag
- Archive template combined with post slider and regular posts
- Migrate posts from category and sub-category via SQL
- Exclude some posts from displaying in wp_query based on some condition
- Bootsrap carousel for post
- WordPress displays post on subcategory only
- Trying to query all posts in category 4
- WP_Query get posts in custom database table [duplicate]
- WP query taxonomy optimization
- get posts, run a custom query, and join the results
- Using a meta_value or postdate to to query and orderby
- Exclude posts in home slider from sections
- Ajaxify Post Sort
- Get current user, change users post status to published
- Blog posts not displaying on blog posts page
- Display WordPress Post By Date
- GUID to related post not in current language
- How can I display a specific number of post in a category via a url
- Advanced Post Display/Pagination/Ordering
- Query Posts From Multiple Post Types
- Displaying Results From Custom Taxonomy Query
- Multiple loops on a Search result page?
- WP_Query: Fetch posts that are in (category1 and not in category2), OR posts that are not in cagegory1
- wp trim function not working
- How add class the_content();?
- WP_Query post_tilte search in posts table