If you’ve dropped it right into functions.php
and not inside an action hook, the code is running before ACF has initialized. Try running on acf/init
action (untested):
add_action( 'acf/init', static function () {
$currentdate = new DateTime();
$date = get_field( 'date_picker', false, false );
$date = new DateTime( $date );
if ( $currentdate > $date ) {
echo '(Deal Expired)';
} else {
echo get_field( 'date_picker' );
}
} );
Related Posts:
- Organizing Code in your WordPress Theme's functions.php File?
- How to check if a user is in a specific role?
- Can’t change language (only “English (United States)”)
- Create WP tutorial for users with admin pointer using next button for navigation
- Taxonomy dropdown metabox in the back-end
- How to redirect/rewrite all /wp-login requests
- Add “external” link to admin menu in the backend
- Disable image attachment links
- Remove “Time to upgrade” message from dashboard
- How can I enable Google Analytics on a file download link?
- Pre-fill fields with content from outside when creating a new post
- Why are admin scripts not printed
- White screen of death only in wp-admin
- Change the link of ‘Howdy’ at the top right
- wp-admin remove the subfolder URL
- Reorder custom submenu item
- Looking for a hook to add attachment information to the media library tab
- Removing admin bar from wordpress dashboard
- Load Balanced WP with single server admin access
- WP-admin giving 404
- How to control contextual help section by code?
- Can’t access wp-admin Internal Server Error 500
- File exceeds upload_max_filesize, despite max filesize being large enough
- WordPress admin not changing language
- Add custom text to Page Tamplate without need to know html
- Move WP Admin Bar
- Get Stylesheet To Showup in WP Admin Panel Editor
- Deprecated : contextual_help has been deprecated since version 3.3.0
- Just how ‘expensive’ is this function?
- Custom Background-Image not showing up
- js Conflict in admin panel – I guess it’s from the core WP installation
- Why is there an intermediate redirect to https://public-url.org/wp-admin?
- Remove query var on admin pages when ‘Save changes’ pressed
- How to hide wordpress default description box?
- Create a fullwidth dashboard widget
- admin_url in plugins
- Website looks fine, but login to wp-admin yields a blank screen
- cannot find the login page for local WordPress site
- In editor-style.css how can I change background color of title field?
- /wp-admin/ 500 error
- Where did the screen options menu go?
- How do I change the upload file size limit in single-site wordpress install?
- Can’t call external stylesheet for WordPress admin (using wp_admin_css)?
- wrapping ‘rest_api_init’ in ‘is_admin()’ function
- display dynamic WP Site logo on wp-admin using CSS
- Restore a layout [closed]
- Logging into sandbox subdomain WP
- White screen of death on admin and other dashboard pages
- TinyMCE strips breaks inside editor
- can not access wp-admin after migrating to openshift
- wp-admin url doesn’t allow to login and redirects to same page
- wp-admin dashboard redirects to homepage
- Can I hook into wp_update_core outside of the admin?
- /wp-admin/ doesn’t work but /admin/ does
- WordPress Side Menu Admin Panel Default Order numbers List?
- Why can I log into wp-login.php and not wp-admin.php?
- Change admin defaults for reading settings
- wp cron, admin and updates questions
- Unable to properly login
- Is there a simple way to set wordpress site files back to out of the box?
- Remove header text option from the backend
- User Capabilities are not available in WP REST permission callback?
- How to check if it’s edit.php & post_type is set?
- Dashboard : remove Safari navigator message
- Contextual help in wp-admin for non admins
- Trying to create a page as a menu item in the admin while keeping the admen panel visible
- Weird urls after moving site from local env to a server
- Manage Admin permissions by URL GET parameters
- Set edit capability based on ACF relationship
- Step by step guide for new users on how to post content?
- Hook into form handle from admin users table
- Display Form in Admin Panel and Save data to Database
- Give wp-admin access for shop managers
- Cannot log in to WordPress admin or change password
- 403 Error when using save buttons
- Js errors in wp-admin
- Avoid executing a function (redirect) if I’m in the admin area
- Wp-admin loguts me. When sign with Wp_singon
- Localhost install: Administrator lost administrator access; cannot access Dashboard
- How to keep the plugin submenu open on viewing a custom version of users.php?
- Admin Panel issue
- sharing wp-include – wp-admin on same installation
- admin_print_styles incuding $_SERVER[‘DOCUMENT_ROOT’]
- Admin Scripts enqueue codes seems ok but not working
- admin-post.php results on white screen after form submission
- CSS not showing up in my website Only HTML Displaying
- Change height of Add New Post input box
- Anyone Can Register
- How to protect wp-admin from third party access?
- Unable to access my plugins [closed]
- Can admin-ajax.php be used for spam purposes? And if yes, how to prevent that?
- WP-Admin not reachable
- How Can I Prevent Admin User Role Loss?
- Only Admin receives email
- is exposed wp-admin site a serious security vulnerability
- fails upload images in posts + wp-admin/upload.php 403 error
- Admin utility classes?
- User can see and enter the WordPress Admin without login
- When typing, comment bar opens all the time in wp admin
- check if the admin is inside the specific page on the back end