With some more googling:
<?php
$today = date("Y/m/j");
query_posts(array(
'post_type' => 'custompost',
'posts_per_page' => 4,
'meta_key' => 'mydate',
'orderby' => 'meta_value',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'mydate',
'meta-value' => $value,
'value' => $today,
'compare' => '>=',
'type' => 'CHAR'
)
)
));
if (have_posts()) :
while (have_posts()) : the_post();
?>
<a href="https://wordpress.stackexchange.com/questions/59767/<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
I hope it will help others!
Related Posts:
- Ordering posts by anniversary using only day and month
- Ordering posts by custom field named “date” in backend
- Sortable Custom Columns not sorting correct
- How to query posts by month based on date custom field?
- WordPress Admin – Automatically Sort Custom Posts by Custom Field Date Value in d-m-Y Fomat
- Order a query by meta_value and then by post_date
- WP_Query – Order results by meta value
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Max length of meta_value
- ORDER BY custom field value
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Sort posts by custom field numeric value using dropdown
- How can I display all values of a custom field from posts with a certain value of another custom field or from certain post types?
- Date, Time, and Timezones
- get_pages sort alphabetically by meta value
- Trying to perform complex custom field query with order by set to field value
- Order Posts by Closest Numeric Values
- Is there a way to do multiple ordering on a multiple meta_query?
- Order by custom field date?
- Assign/update the custom field value for all posts
- Order Custom post type loop by custom field (datepicker)
- Sorting within nested queries / multiple meta keys
- Order by Custom Field date not recognized
- Comments form custom fields order
- If value present, order posts by two consecutive custom fields
- How to break meta values into different items and avoid duplicates?
- Localized Date Format for Custom Field
- How can I query on the year part of a complete date in a custom field?
- WP_query : meta_key with custom rule for specific value
- Displaying posts with only upcoming dates according their custom field date value
- Ordering by meta_value AND date NOT WORKING with wp_query
- Sorting posts by multiple values, combined
- Sorting posts by custom fields in meta_query
- How to sort category by custom field value
- trim custom field text value and show (…)
- Query post order by post and desc not working
- How to wrap meta values seperated by comma in ? [closed]
- How to create a Custom Meta Box with Name/Value Admin User Input Fields?
- Run a check for multiple meta key values
- Filter by custom field (meta_key) using JSON API
- Order RSS content by an advanced custom field value
- Removing link ” from ” on meta_value in custom feilds
- Alter main archive, to show posts with meta as last
- Sort alphabetically by custom field
- Trying to sort and display categories(not posts) by custom field: ‘order’
- Change order of posts
- Meta query with multiple custom fields for archives page ordering problem
- query posts custom field calculation value
- WP Query – Is this correct?
- Using abs() with custom field in orderby statement
- pre_get_posts : only get posts by wp_usermeta value
- ORDER BY custom field value out of where clause
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- meta_value and meta_key filtering returning no posts [closed]
- IF Custom field value equals ZERO
- List custom field values in alphabetical order without repetition
- How to update a custom field in all posts with the value of another custom field in the same post?
- Update post meta custom field using block editor
- How to add custom filed value after in wp post title
- Convert all dates stored in custom field
- query_posts with meta_value
- Order custom fields alphabetically
- Ordering by ‘Title’ OR ‘Custom Field’
- Show array of meta_value in Edit Post Coloum
- How show post only from after custom date
- Problem with writting correctly a query posts args in WordPress
- Order by custom date field
- Group Posts By Custom Meta Value: Date
- Making WP_Query limit results by date before today where date is a meta_query
- User query – getting values for custom meta keys/fields
- get posts based on non-single metadata
- Set class if a meta value is set within post archive
- Ordering by ACF custom field vaule
- Sort by an ACF field in a tax_query
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- (woocommerce) How to get product id form order id & then retrieve custom meta linked to product?
- How do I display posts ordered by a date custom field?
- Create Shortcode shows only posts with custom_field meta
- 4 Unique Random Posts based on Custom Field Values
- How to properly get popular Posts by multiple Values
- Thirtieth century date for a post
- How to display custom post type ordered by a custom field date
- Custom Field: Display only if a specific key is selected outside the loop
- WordPress archives by custom field and date
- Order by custom field in query multiple
- Complex WP_Query Using Post Date And Post Meta
- Checking if field is set before comparing with meta_query in query_posts?
- Display posts where date field matches current month?
- Can’t sort custom column on user.php by number / meta_value_num?
- Dynamically update Custom Fields to display new dates
- WP Query Args – search by meta_key or title
- Saving multiple custom meta box fields
- WP_Query sort by ACF date field (newest first) with blank dates first
- get Custom field label (select/dropdown) on front end
- Custom Meta Box not Saving in Posts with Gutenberg Editor
- Update Custom post field by Ajax on cached site
- How to display a WordPress Custom Field only on a specific day of the week?
- update_post_meta
- update_post_meta not working well
- Multiple permalinks for a single post from custom field