The problem with orderby rand is that on most setups the database will load all posts into memory, then randomly order them, and return what you asked for. It’s that loading into memory that makes the query super slow/expensive
Also yes, terms are individual categories and tags, where category is a taxonomy, and the ‘development’ category is a term in that taxonomy.
Finally, your initial code snippet implies you’re using a page template or attempting to override what’s shown on the page. This is bad as it discards the main query and launches a second query. The cost of the first query still occurs, but it’s discarded so it’s a waste of time. This is why query_posts
is considered harmful, replacing it with a custom WP_Query
loop doesn’t fix that. Consider using pre_get_posts
instead to intercept the main query and change it
Related Posts:
- Exclude posts with empty post_content in wp_query
- posts_per_page option limits the number of Gallery items
- Query for first 3 posts to change the look and feel
- How to give classname to post if post has no content?
- Show 5 posts and than 3 posts offset with pagination
- 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 to limit the number of posts that WP_Query gets?
- Should we trust the post globals?
- Random sort within an already sorted query
- How to exclude latest x posts from a paginated query?
- How to know if get_posts() failed?
- Query posts distinct authors
- How to get previous 10 days post from a specific date – WP Query
- WordPress Number of Posts Not Changing With posts_per_page
- I have over 4000 posts, will querying some of them cause performance issues?
- How to add posts to wp_query result?
- Order post by year DESC and month ASC
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- Search query – exact post title match
- Hiding posts in a list from specified categories
- posts_per_page doesnt work
- How would I get 1 latest post from a query for 5 posts?
- How to start with post number x?
- Only display a certain number of posts, dependent on how many posts there are available in a query
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Reset Popular post query?
- Get Posts that are in the current month or later
- 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?
- Slow page loads due to WordPress Core Query
- Random ajax load only works with posts_per_page set to -1
- Exclude the first ‘n’ number of posts of a tag from home page?
- 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 Query is returning empty array?
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- meta_value timestamp older than now
- Counter is skipping post when I still want it visible [closed]
- Do not show children of a category
- why the same code got different results when using query_posts in functions.php and index.php
- How to get posts published on the latest date?
- Why posts array is empty?
- 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
- WP_Query: Show 10 posts in date order, first three random
- Exclude some posts from displaying in wp_query based on some condition
- Random posts that always include a particular post?
- Related Posts function not working
- How to retrieve certain number of images from a wordpress post?
- WordPress post filter menu
- How to convert query sql to shortcode in wordpress?
- 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
- How Can I Always Display A Particular Post First Using WP_Query?
- WordPress Query – Display 5 posts (same post type), each from a given tag
- Show posts from two specific category in WP_Query
- Check if almost 10 year old – working code is up to date
- 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
- How to fetch courses in all languages in WordPress?
- Multisite how to display merged posts from two sites and sort by latest date?
- filter posts based on menu_order
- wp_query args with relation
- Manipulate query to show specific post
- Querying posts from current category, using a variable as array argument
- Sort Events by Venue Title – Sort Post set by related post ids
- wp query custom orderby not custom field
- Query post category & remove any post id
- Advanced Post Display/Pagination/Ordering
- Ordering posts alphabetically by meta keys and title
- How do I control the fallback query after the original query returned cero posts?
- Remove duplicated posts in the loop if post has more than one category
- Adding a category at even positions on main loop with modified pagination
- Query Posts From Multiple Post Types
- Displaying Results From Custom Taxonomy Query
- WP_Query retrieve custom posts but not the post showing
- wp_query select if have comments
- Creating pages and getting their values from the database table
- How to limit post query to only return a total count of items with certain post statuses?
- Wp_query WooCommerce products
- query_posts different amount of posts per page [duplicate]
- Sort Posts Alphabetically Based on Specific Category (Divi)
- Query only Posts from Both of Two Category?
- Pausing and Resuming WP_Query results
- Conditionals if tags exist?
- a WordPress connected to 2 database
- Optimising specific Query with ACF meta objects
- How to modify this function to exclude also the post belonging to a specific category?
- List posts related to category on a div [closed]