Conditionally including JS based on whether ACF field is set [closed]
The Loop isn’t available yet in wp_enqueue_scripts, so is_single() etc pp aren’t going to work. However, the queried object has already been determined, so you could use something like add_action(“wp_enqueue_scripts”, function() { $qo = get_queried_object(); if(get_class($qo) == “WP_Post”) { if($val = get_field(“my-field”, $qo->ID)) { wp_enqueue_script(“jquery”); } } });