BUG REPORT: Taxonomies mapping in Advanced Post Creation

Hi there,

There is a bug in Advanced Post Creation.


  • Set a Select field, and enable “populate with a taxonomy”.
  • In Post Creation mapping, add a mapping to store the Taxonomy.

Then, when you post the form, it will create a new category, which is numeric.


The GF select field, when populated with a taxonomy, sets the value as the Taxonomy ID, and the label as the label.

In Advanced Post Creation, the mapping of existing taxonomies is in the function get_taxonomy_mapping_term_ids:

foreach ( $values as $val ) {
	$existing_term = get_term_by( 'name', $val, $taxonomy );
	if ( $existing_term ) {
		$term_ids[] = $existing_term->term_id;
	} else {
		$new_term = wp_insert_term( $val, $taxonomy );

You can see that the taxonomies are searched by their name, and not by ID, which breaks everything. The taxonomy is not found, and a new one is added with the label corresponding to the ID.

Proposed solution

The mapping of the taxonomies should rely on the same principle than Wordpress: if this is an integer, you should call:

get_term_by('id', $val, taxonomy);

And if it’s a string, by:

get_term_by('name', $val, $taxonomy).

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