Home › Forums › Backend Issues (wp-admin) › Save_post and a choice field with dynamic taxonomies › Reply To: Save_post and a choice field with dynamic taxonomies
$htmlAfter = '<input type="hidden" name="tax_name" id="tax_name" value="ENTER_MAIN_TAXONOMY_SLUG">';
$htmlAfter .= '<input type="hidden" name="tax_slug" id="tax_slug" value="ENTER_INDIVIDUAL_TAXONOMY_SLUG">';
'html_after_fields' => $htmlAfter
function my_acf_save_post( $post_id ) {
if(isset($_POST['tax_name']) && isset($_POST['tax_slug'])) {
wp_set_object_terms( $post_id, $_POST['tax_slug'], $_POST['tax_name'], true );
}
}
// run after ACF saves the $_POST['acf'] data
add_action('acf/save_post', 'my_acf_save_post', 20);
I know it might not be 100% related, but this idea could be applied in MANY ways, considering where ever you include acf_form, you could use whatever variables are available and then include that data in input values and then include those inputs in the html_after_fields or html_before_fields parameter for the acf_form function.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
π Weβre excited to announce we've released Composer support for installing ACF PRO.
— Advanced Custom Fields (@wp_acf) January 31, 2023
π #ComposerPHP fans rejoice!
β¨ Please see the release post for all the details and full instructions. https://t.co/ebEfp61nlR
© 2023 Advanced Custom Fields.
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.