change your query a bit:
$todays_date = time();
$args = array ('post_type' => 'tasks',
'meta_key' => ''end_date,
'meta_compare' => '<',
'meta_value' => $todays_date,
'orderby' => 'meta_value'
);
$tasks = get_posts($args);
and then for each one of this posts get the start_date meta and compare with $today something like:
$today = strtotime($today);
foreach ($tasks as $task_post){
$start = strtotime(get_post_meta($task_post->ID, start_date, true));
if ($today > $start){
//to task stuff here
}
}
Hope this helps.
Related Posts:
- Get the ID of the latest post
- Number of posts in the archive
- Help ordering custom query by Title, Ascending
- How can I show a field ID in Elementor with Request Parameter
- Custom post type posts don’t show in archive widget
- Showing specific post in order of array wp_query
- Reworking function for counting custom post type posts count
- Get only used meta_values
- Query of custom post types only shows first post
- Adding custom field values to wp_list_pages
- Query multiple taxonomies with pre get posts
- How to query 2 custom post types that need to share a slug?
- Recoverable Fatal Error – Object of class WP_Post could not be converted to string
- Query Custom Post Types with checkboxes
- WP_Query() with custom post type and taxonomy — get all terms?
- show all custom posts types in home page
- List of child custom post types lists all custom post types
- Query custom post type based on post id and custom field value
- populate array with posts
- Listing custom post types on archive page with array
- How to Make infinite loop of post
- Make (custom) post type accessible only by custom query
- get_posts seems to be skipping the last Post
- Displaying multiple post types on home page
- Can I query posts by taxonomy conditionally based on post type?
- Conflict between wp_list_pages and get_posts – list pages not displaying
- How to conditionally add Custom Post Type to Front Page
- Graphql: Unable to query (where:{author}) for custom post type
- Return number of all custom posts type by author in all statuses
- Query not work for current taxonomy
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- Returning a custom content types with meta values
- Is it possible to use array_walk() to append terms to an array of posts?
- custom hierarchical taxonomy and custom post type list contains surplus posts
- Custom Query: If One Post Object Field Value Is The Same As Another
- Break up posts per page in two sections
- Custom Post Type not showing in main loop
- Custom Post Type setup
- new WP_query > displays posts only once instead of running through full array
- Pagination on search results page
- Querying a custom post type, but not show duplicates
- Shortcode to return single custom post based on post taxonomy
- is_main_query() never called on WP 4.4
- Group by custom field value (start and end times)
- meta query not retrieving posts
- Hide text if query has no posts
- How do I get the index for a custom post?
- Getting custom post types to properly display alphabetically
- Create query for both custom post type and category
- Filtering custom posts by custom fields (ACF) [closed]
- How to get custom post type title, excerpt, thumbnail and permalink by post ID?
- Function to limit number of custom post types on homepage – TwentyTen
- Get posts by category name
- Why the_excerpt() function returns excerpt on the Home page and trimmed content in sidebar?
- Custom taxonomy query showing more than 4 posts
- Custom types, taxonomies and query optimization
- How to properly use Categories with Custom Post Types
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Query Custom Post by taxonomy multiple categories
- 4 posts per page from single category
- Query custom posts from custom taxonomy
- Custom Post type showing up in loop, regular posts are not showing up
- All in one calendar custom post type query doesnt work as expected
- Query custom posts of logged in user only
- Display a random customposttype2 excerpt in single-custompostype1.php that shares same taxonomy
- Getting the list of the latests posts and custom type posts in the homepage
- Changing WordPress sort order for returned child pages
- Add custom post type to query
- How to query custom post types with multiple keys?
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- date_query empty results with custom post type
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- How to divide Subcategories into pages of parent category wordpress
- Update query based on CPT / Post Type, show all sorted by date
- Query filter by value in meta_value array
- Change search query in wordpress custom post type
- get_posts() returns empty on custom post type /wp-admin/edit.php
- WP Query from two Custom Post type fields as statement
- Get_post_custom not fetching value from array wordpress
- WP Query: If field X is empty, show posts based on field Y
- Check that a slug is present in the get_terms request
- I’m having trouble with Related Product “tax_query” ‘terms’ value
- Using OR relation in meta_query to check for a value before sorting by another
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Custom post type data not displaying If I select the category from the dropdonw
- Does this archive template part look like its making too many calls to the db?
- Shortcode with loop stacks output
- Displaying all posts by category and showing content on click
- get_posts wont produce a list of custom type from a given category [duplicate]
- Limiting the Number of User Posts to Their Own Posts
- Meta query and compare “!=” not working as expected
- Get all posts by many custom post types
- Modify default Related Posts Code to Custom Post Type
- Creating a custom WP query for a Custom Post Type
- How select query is generated in a Custom Post Type?
- Custom post type order by post_title
- WP_Query for custom taxonomies showing posts from non-specified terms?
- How do I query with multiple custom fields orderby in same column?
- How to hide sub fields in a field group and also the entire field group if the answer selected is “no”
- WP_Query with all posts in one custom post type and only posts in another custom post type with a specific category