WP_Query retuning empty array in rest api
WP_Query retuning empty array in rest api
WP_Query retuning empty array in rest api
You can use get_posts() for both event types and merge them. $merged_events = array(); $upcoming = get_posts(array( /* Your upcoming events args here. */ )); $past = get_posts(array( /* Your past events args here. */ )); $merged_events = array_merge( $upcoming, $past); foreach( $merged_events as $merged_event ) { //Your loop }
Assuming that you’re trying to get all posts in the first half of 2022, as opposed to the first 6 days of 2022, then you need to be clearer with your before and after dates. date_query uses strtotime behind the scenes, which will interpret your dates as Jan 1 to Jan 6. You need to … Read more
How to add date_query to meta_query array
As others have already noted in the comments, using “posts_per_page” => 5, is better option than “posts_per_page” => -1, for your query as it will give you the information you need for your conditional check. Limiting what is queried is also something to consider – as honk31 mentioned. Along ‘fields’ => ‘ids’ you can also … Read more
WP query taxonomy optimization
Related posts by current posts child category
How to search by slug and old slug in single API
search.php to search only the post title
Query multiple post types, but different order for each