ACF Custom validation message not showing up

Add this snippet and check according to your needed. add_action(‘acf/validate_save_post’, ‘my_acf_validate_save_post’); function my_acf_validate_save_post() { $start = $_POST[‘acf’][‘field_5fb0e816ea4fc’]; //$start = new DateTime($start); $start = strtotime($start); $end = $_POST[‘acf’][‘field_5fb0e83aea4fd’]; //$end = new DateTime($end); $end = strtotime($end); if( current_user_can(‘manage_options’) ) { acf_reset_validation_errors(); } // check custom $_POST data if ($start > $end ) { acf_add_validation_error($_POST[‘acf’][‘field-600e609de8ab8’], ‘End Date should … Read more

Trouble With Conditional Logic in PHP

Did you tried dumping the value of $carousel_image For image field to return Array, return_type must be set to array https://www.advancedcustomfields.com/resources/register-fields-via-php/#field-type%20settings /* (string) Specify the type of value returned by get_field(). Defaults to ‘array’. Choices of ‘array’ (Image Array), ‘url’ (Image URL) or ‘id’ (Image ID) */ ‘return_format’ => ‘array’, Also what’s the use of … Read more

How to display Custom Post Type Post based on Tag with Shortcode Parameter?

This is an answer that depending on how you ultimately configure things – should get you where you want to go. In your question, you had posts_per_page as 1. If you only want 1 result, then that’s fine. If not… modify as shown. You also didn’t initialize the concatenated string $return_string and finally you put … Read more

How To Fix WP Query Returns Results But Shouldn’t?

Couple of things to consider here: 1.) Try adding the meta query only if the value is present: $pairedThing = get_field(‘myThing’); $args = [ ‘posts_per_page’ => 2, ‘post_type’ => ‘thing’, ]; if ( ! empty( $pairedThing ) ) { $args[‘meta_key’] = ‘identifier’; $args[‘meta_value’] = $pairedThing; } 2.) Account for posts without the meta-key set: $pairedThing … Read more

list/consult Taxonomy only for the respective author/creator in dashbboard

The WP_Term_Query class doesn’t have a method named set, and calling $query->set() in my case resulted in a fatal/critical error saying “Call to undefined method WP_Term_Query::set()“. :/ But you can directly modify the query_vars property (i.e. $query->query_vars), like so, to set, unset or override any query variables like meta_query: // Use this: $query->query_vars[‘meta_query’] = $meta_query; … Read more

Advanced custom fields sort repeater by date

I think this is not possible with the API functions provided by ACF. I would try to save the values to a temporary array first and then sort the values inside the array with php (using krsort() for example). Something like this (just to give an idea): while(has_sub_field(‘in_the_news’)) { $date = get_sub_field(‘published_date’); // $date = … Read more