A have a lot of posts with custom post types in the database. In the same time the theme created the taxonomy institution:
function my_taxonomies_institutions() {
$labels = array(
'name' => _x( 'Category', 'taxonomy general name' ),
'singular_name' => _x( 'Category', 'taxonomy singular name' ),
// and tothers
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
'show_admin_column' => true,
'rewrite' => array( 'hierarchical' => true, 'slug' => 'institutions' ),
);
register_taxonomy( 'institutions', 'institution', $args );
}
add_action( 'init', 'my_taxonomies_institutions', 0 );
OK, there's a menu item Instituitions in admin zone, and a bit of Categories there, for example - Sections. Now in order to animate the theme that constructed for this taxonomy I need to go through all posts and to attach the Instituitions term to the post depending of it's post_type.
print term_exists('sections'); // 7
I tried the following
$ret = wp_set_post_terms($pid, 7, 'institution');
$ret = wp_set_post_terms($pid, 'sections', 'institution');
but result was
WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Неверная таксономия. ) ) [error_data] => Array ( ) )
What I'm doing wrong?