You’re trying to make WP_Query
give you everything in a single API call, but that won’t work.
Instead, break it down into multiple steps, e.g.:
- Create an empty list
- fetch all the posts
- foreach post:
- add its ID and name to the list
- you now have alist of ID’s and names
Related Posts:
- Getting posts to exclude from array
- Search.php gets metadata from first post
- in_array not working on dev server but works on localhost
- Query multiple custom post types in single loop
- Inject post (from specific category) between posts in Loop
- Build a content and excerpt grid loop with paging and options for # of posts
- Guidance with The Loop for CMS
- Alter secondary loop to exclude posts from current page category
- How can I loop into two different DIVS without repeating the DIVs
- Looping through WP_Post Object
- WordPress loop specific thumbnail size
- Can an array be used as a meta_query value?
- How do I dynamically generate args for wp_query?
- Must Use Plugin Causing Query Error
- How to get to a specific position in wp_query?
- have_posts() execution failure
- Using a variable in is_page(array())
- How can I add multiple ‘tax_query’ arrays via a loop?
- Using foreach loop breaks
- get_the_tags() not iterating through for/while loop, but will with foreach
- How to use $query->set with post__in?
- Exclude posts based on meta value
- Recent Posts Not Showing Only On A Specific Category Page [closed]
- Checking array against author id in loop
- 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
- Redirect to another page using contact form 7? [closed]
- Syntax error when I try to insert my loop into an unordered list? [closed]
- WP_Query fails despite having 1 post
- wp_query get the 2nd post
- How to get post ID in a Page?
- Display an image if odd number of posts in grid
- How to add div blocks after certain set of post
- How to overwrite orderby with add_query_var
- What file have I to create in my custom WordPress theme to show all the post belonging to a specific category?
- Why in my theme I can’t see all the statics content under the posts?
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- get_the_ID() in the footer returns wrong value
- How to get the last category name of a child category?
- WordPress loop by meta key that is an array? and how loop multiple arrays
- Only show first image in foreach loop
- home.php show blog posts as grid view
- Custom post type permalinks do not appear using the link functions
- extract serialized array to use for wp-query
- WP_Query multiple post results
- Do not duplicate posts with multiple categories in multiple loops
- Infinite Loop – WP_Query
- How can I split my query result in 2 arrays?
- array_rand not working correctly?
- Dividing the loop to style post differently
- Get css class of menu item in custom menu structure
- Order a WP_Query by meta value where the value is an array
- How to extract information from a wp_query result?
- How to make sure relative URL works when site is not on root domain?
- Toolbar Hidden in a Virtual Page
- Using multiple variables to assign categories to an array
- the_post(); prints out style text into my HTML?
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- Wp Query : Order by distance lat,lon
- Sending simple variable on single page to WP JSON
- Check if current post in loop is last on current page
- Looping through dummy posts and showing them in the main index.php
- Trying to get pagination working on WP_Query() post grid
- ACF – Get ID of relationship field in flexible content
- Show the subcategory name based on current product
- How to display sticky post always at the top (before regular post) in wordpress?
- Combine multiple queries, array_unique returns nothing
- Making list of posts with chosen description
- Problems with the WordPress loop [closed]
- How to replace hard-coded list of custom taxonomy terms based on custom field query [closed]
- My query keeps looping infinitely ! how to stop it?
- Efficient way of querying for a “fallback” post?
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- For each 3 posts, show a different post type
- Add post class in custom loop (WP_QUERY)
- Create a hierarchical loop at predefined markup requirements
- WP_Post is not from correct array
- Create Customization Controls from Array
- WP Knowledge Base Theme bug – Subcategories and Articles, Need to change WP_Query
- Advanced Taxonomy query, with 3 post types
- Trying to display ads on only a third of posts in a loop. Keep getting Error 500?
- Why does a meta_query break this WP_Query?
- WordPress post pagination on custom template not working
- Pagination in category.php not functioning
- Pagination not working properly
- $_html is empty when var dumped
- Variable ++ in query loop
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- How to use a conditional statement in a post loop but not count towards the “posts_per_page” if false
- How do I exclude the current post from the upcoming post query
- How do I display WooCommerce products in my query to rows of 3?
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- WordPress theme options error
- How can I use the WordPress Loop and Pagination in multiple instances but different scenarios throughout my site?
- Get categories names as an array to use it in theme settings
- Custom route and query
- Validate and Sanitize WP REST API Request using WP JSON Schema?
- Insert div after every three posts in home.php [duplicate]
- insert thumbnail image from php script
- How to sort custom sortable column by custom table value