meta-box icon indicating copy to clipboard operation
meta-box copied to clipboard

Taxonomy not saved when creating new custom post

Open joker1t opened this issue 8 years ago • 7 comments

Hi.

I have three taxes, shown by meta box in my custom post type. Custom post type created via Toolset Types plugin.

So, when i create new post and select one term of my tax, selection is not saved. But, if i do it in second time, selection is saved.

PS: wordpress 4.7.3, meta box 4.10.4, toolset types 2.2.9

joker1t avatar Mar 30 '17 20:03 joker1t

Can you post your code and screenshot?

PS: Have you tried MB Custom Post Type extension? It creates custom post types for you. And it's built on Meta Box and very lightweight.

rilwis avatar Apr 03 '17 09:04 rilwis

Code is above:

add_filter( 'rwmb_meta_boxes', 'new_tax_meta_boxes' );
function new_tax_meta_boxes( $meta_boxes ) {
    $meta_boxes[] = array(
        'title'      => __( 'Выберите Страну, Регион или Город', 'textdomain0' ),
        'post_types' => 'offers',
        'fields'     => array(
                        array(
				'name'       => esc_html__( 'Город', 'textdomain1' ),
				'id'         => "taxonomy_1",
				'type'       => 'taxonomy',
				'taxonomy'   => 'cities',
				'field_type' => 'select_tree',
				'query_args' => array(),
			),
			array(
				'name'       => esc_html__( 'Регион', 'textdomain2' ),
				'id'         => "taxonomy_2",
				'type'       => 'taxonomy',
				'taxonomy'   => 'regions',
				'field_type' => 'select',
				'query_args' => array(),
			),
			array(
				'name'       => esc_html__( 'Страна', 'textdomain3' ),
				'id'         => "taxonomy_3",
				'type'       => 'taxonomy',
				'taxonomy'   => 'countries',
				'field_type' => 'select',
				'query_args' => array(),
			),
        ),
    );
    return $meta_boxes;
}

Screenshot (new post in a custom post type) image

joker1t avatar Apr 03 '17 13:04 joker1t

Nut sure why this is. Maybe the taxonomies aren't available yet when the terms are trying to be saved.

funkatron82 avatar May 05 '17 03:05 funkatron82

same problem but: Terms are sometimes saved and sometimes not. From what i see it random ;/ and when i add 'clone' => true after save i get wall with :

Notice: Array to string conversion in /srv/www/holistic/public_html/wp-content/plugins/meta-box/inc/fields/taxonomy-advanced.php on line 43

Karuma avatar Jun 01 '17 10:06 Karuma

Think the problem is from line 80 of meta-box/inc/fields/taxonomy-advanced.php.

Think it should be checking for 'cloned' parameter, in addition to the 'multiple' parameter.

Result: return ($field['multiple'] || $field['clone']) ? $meta : reset( $meta );

joshbourke avatar Jun 26 '17 15:06 joshbourke

@Karuma taxonomy fields shouldn't be cloned, as it isn't supported

funkatron82 avatar Jun 26 '17 20:06 funkatron82

I have the same issue, When I make custom page + select tree view taxonomy, I cant save my post. Any idea where is the reason? Latest version of all.

Thanks

etom-project avatar Aug 01 '17 16:08 etom-project