Assign custom taxonomy on post creation [RESOLVED]

Hi guys, I’m creating a form for creating a custom post type.
Using the drop-down menu, I populate everything with the taxonomy I need.

In the settings if I put “value” but it creates a new taxonomy with the number.
How do I assign the correct taxonomy?

Screenshot 2023-02-08 alle 11.55.00
in this case it assigns the drop-down menu value but not the taxonomy name. How can I fix?

Thank you.

Hi Emanuele,

By default the Taxonomy mapping uses the ‘name’ of the Taxonomy for matching to your list. If you’re populating the Taxonomy with the Name as the Label and the Term ID as the Value, you need to use the gform_advancedpostcreation_taxonomy_mapping_field filter to change what ‘value’ is used for Taxonomy to create that mapping match.

There are examples on that page for using term_id and for slug.

Hope that helps!

1 Like

Thanks Jim

i’ve used and now work

// Use term_id instead of name to assign the taxonomy
add_filter( 'gform_advancedpostcreation_taxonomy_mapping_field', function( $field, $taxonomy ) {
	return 'term_id'; // can also use 'id' or 'ID'
}, 10, 2 );```
2 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.