ACF datepicker meta_query Compare Dates in m/d/Y g:i a – Not in Ymd Format

There should not be any need to do this. Even if an ACF Field is using ‘return_format’ => ‘m/d/Y g:i a’, The post_meta value is in YYYY-MM-DD 00:00:00 format. $date_now = date(‘Y-m-d’); $args = [ ‘meta_key’=>’the_date’, ‘meta_value’=>$date_now.’ 00:00:00′, ‘meta_compare’=>’>=’, ]; $query = new WP_Query( $args ); Edit: I’ve noticed some discrepancies in this, the value … Read more

Conditionally loading JavaScript based on the Advanced Custom Fields in the post

ACF has finegrained filters for fields when they get loaded. add_action( ‘wp_enqueue_scripts’, ‘register_my_scripts’, 5 ); function register_my_scripts() { wp_register_script( ‘my-script’, ‘path-to/my-script.js’, array(), ‘version’, true ); } add_filter(‘acf/load_field/name=my_field_name’, ‘load_field_my_field_name’); function load_field_my_field_name( $field ) { wp_enqueue_script( ‘my-script’ ); return $field; } Normally all scripts should be enqueued in wp_enqueue_scripts hook. So you should make sure your script … Read more

Remove Category description textarea

/*remove term descriptions from post editor */ function wpse_hide_cat_descr() { ?> <style type=”text/css”> .term-description-wrap { display: none; } </style> <?php } add_action( ‘admin_head-term.php’, ‘wpse_hide_cat_descr’ ); add_action( ‘admin_head-edit-tags.php’, ‘wpse_hide_cat_descr’ ); If you need to target it to category editor only – in other words leave description for other taxonomies, then easiest will be to position the … Read more

Compare two numeric custom fields

I think something like this, but not tested, and my SQL-foo is rather weak: $test = $wpdb->get_col( $wpdb->prepare( ” SELECT DISTINCT $wpdb->posts.* FROM $wpdb->posts INNER JOIN $wpdb->postmeta AS mt1 ON ( wp_posts.ID = $wpdb->postmeta.post_id ) WHERE $wpdb->postmeta.meta_key = ‘goals-made’ AND( mt1.meta_key = ‘goals-against’ AND CAST($wpdb->postmeta.meta_value AS INT) > CAST(mt1.meta_value AS INT) ) ” )); This … Read more