Support

Account

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.