This answer explains the differences. They all use WP_Query
, all parameters being equal there is no difference in speed, it’s just a question of which is easier for you for your particular needs (hint: it will never be query_posts
, which should basically never be used).
You should query the database as few times as possible, so if you can fetch all your posts with a single query, then do some manipulation via php to get the output you need, that is definitely what you should do versus creating multiple queries. Note that a WP_Query
object contains some helpful vars to assist in output, like $query_object->post_count
and $query_object->current_post
.
You should also be employing a cacheing plugin, like W3TC, if server load is an issue.
Related Posts:
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- WP_Query vs get_posts
- Get posts by meta data OR title
- Meta Query with date and time on the same Day before given time
- How to find out what “Blog pages show at most” is set to [duplicate]
- How do you Query posts with nothing in common?
- add active class based on permalink and url
- Reset WordPress Post Query to default
- Get all posts which was posted on X Days WordPress
- get_posts output always same post
- complex get_posts() query to select child pages
- Posts query according to meta box date
- How to query for a page, get data, then query for child pages of that page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Facing problem with tax_query results
- Ordering Posts by parent category, name ascending
- When should you use WP_Query vs query_posts() vs get_posts()?
- Get post ids from WP_Query?
- Nested meta_query with multiple relation keys
- How to query for most viewed posts and show top 5
- Delete all posts from WordPress except latest X posts
- Using OR conditions in meta_query for query_posts argument
- Sanitation needed for WP_Query or get_posts calls?
- Differences Between WP_Query() and get_posts() for Querying Posts?
- Order posts by ID in the given order
- get_posts with multiple categories
- Use of caller_ get_ posts
- Query Multiple Post types each with own meta query
- How-to exclude terms from the main query the most performant way?
- Get posts by menu ID
- Get the number of posts from the current page results
- WordPress Custom Query to show posts from last x years
- Perform query with meta_value date
- get_the_title($postID) OR get_the_title()?
- Get posts with condition on comment meta value
- Different Results with query(‘s=computer’) vs get_posts(‘s=computer’)?
- how to display active, upcoming and past event with featured listing with pagination
- Multiple search queries on one page
- WP_query category__in not working, only pulls from first category
- How do you query wordpress posts using a math formula between multiple meta field values?
- Page navigation doesn’t show when query category
- Multiple instances of Featured Image Query
- WP_Query, tax_query and term_meta: How to?
- Custom category search box for WordPress
- get_posts – get all posts by array of author
- Query with a meta value inside a given range
- get_posts() not working with multiple statuses
- Store sticky post’s ids in a transient
- Help with WP_Query – Too many mySQL queries
- How to display multiple custom fields with the same meta_key in an ascending order?
- Bypass “supress_filters” in WP Query
- How to display an other custom post type in a different custom post type’s archive?
- How to increase load time of an archive/search page (WP_Query)
- How to count posts with specific arguments
- Check return value of get_posts
- Exclude All Posts Which Do Not Have A Tag Assigned
- Query post with meta value in set of values
- Easy way to write complex queries in wordpress
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- How to get posts by category and by choosing a taxonomy term?
- Get next/prev image/attachment in time with date query
- Function using get_posts() with tax_query not working when called from functions.php
- specific post is not excluded from the loop
- Search for pages with permalink
- Why doesn’t my WP Meta Query return any results?
- Paginate pages with dynamic query
- Trouble Making WP_Query paged
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Optimising WP_Query with ACF Fields
- Filter products on category AND tag
- Query post ordered by meta value that show first post that contained a tag
- get_posts query is taking about 40 seconds to execute
- pre_user_query vs pre_get_posts
- How do I stop the same post showing multiple times in a archive?
- Get posts that match defined arrays of tags
- get_posts return only first result
- How to get meta key list efficiently?
- how to get wp_query posts only first letter of alphabet A?
- trying to change from query_post to WP_Query
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- My entry results are not consistently alphabetized
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- I cannot get tax_query in get_posts() to work with custom taxonomy
- 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?
- Fetching $_POST from Page Template into functions.php
- How to order by datediff in WP loop?
- Use not custom fields in get_posts() meta_query?
- Optimising specific Query with ACF meta objects
- get_posts works but new wp_query doesn’t
- query_posts with sorting on a custom datestamp
- Why WP_Query in functions.php is not working when get_posts works?
- Retrieve posts in custom post type and specific taxonomies
- Query Posts by date range with fixed beginning and end
- Query specific number of posts for each post type in specific order
- Exclude categories and subcategories in QueryLoop
- How do I correctly query posts from a post ID?
- get_posts shows current post, not defined posts with args