Well, the exact server time/timestamp can be retrieve with current_time function. And comparing your date format, it would need to be Ymd. So combining these two thing, the proper comparison for you should be –
$key = get_post_meta( $post->ID, 'Due', true );
$date = date('Ymd', current_time('timestamp') );
if( $key >= $date )
{
// note to retrive the post thumbnail, you need to use get_the_post_thumbnail,
// as the_post_thumbnail function actually echo the output
$html .= get_the_post_thumbnail(null, 'medium');
}
else
{
$html .= '<img src="http://exampleimage.com" alt="">';
}
return $html;
Now, there could be one question in which timezone you are saving the date in the post meta. If the value is sanitized with the server time (as the post_date value is saved), then this is perfect comparison.
Related Posts:
- Convert custom field date format to “WordPress default”
- Most efficient way to add javascript file to specific post and/or pages?
- Display all values of custom a field created with ACF on a page
- How to automatically apply woocommerce product title to all product images alt tags?
- If Custom Field is empty don’t display div
- How to make an meta_query optional?
- Why does this echo values in the wrong order?
- Add custom field to attachments in a specific category
- WordPress returns a wrong date
- How can update custom meta for all posts
- Unique key for each row in a repeater field
- get_post_custom single array
- Make custom field meta not display if there is not data in it
- wrong php date()?
- how to increase custom post value by one most efficiently?
- Passing the custom field values in the wp_get_current_user array function
- Custom profile field with birthday. Troubles with
- wordpress allow user to edit user profile with custom fields
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- auto-populating custom nav with all items from custom post type
- Automatic Shortcode Creation with Custom Fields [closed]
- Custom field values to taxonomy terms
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- How to combine 2 php functions into one function with a custom field
- Saving zero in meta box
- 3 different times on my WordPress website
- How to check if a PHP string is different than meta field?
- Display custom field on 404 page outside loop
- Only show image from custom field when present
- Hide Heading if ACF Field is empty
- Custom meta box values are not getting saved for my custom post type
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Creating an image from a custom field
- User Meta Value not echoing despite Var_Dump Showing correct string
- WP All Import / Update stock quantity from multiple XML files
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Concatenate Custom Field Value & HTML Value
- Output custom text field as unordered list
- `update_post_meta` not working anymore
- Order a WP_Query by meta value where the value is an array
- Unable to render custom field after attempt to generate a list of recent post in page template
- Add a custom class to the body tag using custom fields
- Hide a div when a custom field is empty
- Conditional On custom field plugin metabox
- Adding custom url to readmore link using get_permalink()
- Filter unique custom field value based on custom taxonomy category or other custom field
- Add “alt” Attribute to GD Star Rating Tags
- Display background color or image with custom meta box?
- custom header text
- Meta boxes only displayed when editing normal (default wp post_type) posts
- WordPress stripping out custom field tags
- Can ‘Custom Field’ data be inserted into this Short Code?
- Using an “IF” statement based on the existence of custom field
- Query pulling a single post per month
- Add custom fields from different posts
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- Adding a custom meta field with default NULL value which is not selectable
- How do you save the values from custom fields to a products data
- Order category posts by last word of custom field
- Products listing check if meta checkbox is checked
- Is it possible to update the dataset using update_post_meta
- How to update custom fields when post is published?
- Hide a div if the fiels is empty
- Inserting a class on before_widget if checkbox is checked
- What is the correct way to search 3 custom fields only in WordPress?
- wp_get_nav_menu_items() with ACF
- How do I get the value of a current user’s custom field?
- Get field in readable word
- How to display custom field from a gallery thumbnail?
- Get meta_query value by user meta array
- Getting a value from a custom field from a page that shares a parent with the current page
- Custom fields changes the formatting of metabox input
- Include a custom field in mysql query
- Display Year and Month from custom field + Age Calculator
- Display Content Based on Custom Field Value
- If custom field doesn’t exist, or exists and it’s true show title?
- How to link a word comprised of a custom field with another?
- Custom field in title
- How can I put a custom field as the link of a button shortcode?
- Custom fields randomly stop working
- Where can I find the code for the menu page meta boxes?
- I want Page titles and excerpts to show up on home.php in certain order
- Posts sortable column not sorting properly for custom field numbers
- ACF Date fileds to Age Convert [closed]
- Save custom field value to variable for conditional – why is this not working? [closed]
- Appending an ACF custom field to the page title
- Display Current Time using shortcode
- Change date/time format in custom plugin
- Displaying custom meta box value in a custom post page
- I want to show image from custom field image on my custom page template
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- ACF number less than comparison not working
- fetch from an external api call and display results in page
- Problem with custom user fields default value and retrieval
- hide “Open in New Tab” checkbox in link field
- Date not working correctly
- Custom rest fields not loaded in rest api cpt response