Impossible without a trick to use get_field in ajax (admin_ajax)
-
Good morning,
It is complicated to use get_field in ajax via admin_ajax.php
Indeed, in the “acf_ct_filter_pre_load_value” hook, a test is done
“if (is_admin() === true || $is_get_field_support_disabled === true) { return null;}”
which makes it complicated to use ajax because in admin_ajax.php there is this from the start:
if ( ! defined( ‘WP_ADMIN’ ) ) { define( ‘WP_ADMIN’, true ); }
and therefore is_admin() = true
One solution is to use “set_current_screen(‘front’);” at the start of the ajax php template.
The other solution is to use “get_custom_table_field” instead which poses a problem with the use of the acf / “twig-timber” couple
The simplest thing would be for the hook to take into account the use of ajax on the front end without having to add code for it to work.
- The topic ‘Impossible without a trick to use get_field in ajax (admin_ajax)’ is closed to new replies.