Создание собственного плагина WordPress, в котором категории и подкатегории будут создаваться на основе данных, полученных из сторонних API.Для тестирования я использовал
wp_insert_term
Это работало нормально для одного сайта WordPress.Но это не работает в WordPress MultiSite.Учитывая, что я начинаю с создания плагинов WordPress.
Ниже приведен код, который я использовал на одном сайте WordPress для создания категорий и подкатегорий.
wp_insert_term(
// the name of the category
'Category A',
// the taxonomy, which in this case if category (don't change)
'category',
array(
// what to use in the url for term archive
'slug' => 'category-a',
));
wp_insert_term(
// the name of the sub-category
'Sub-category Level 1',
// the taxonomy 'category' (don't change)
'category',
array(
// what to use in the url for term archive
'slug' => 'level-1',
// link with main category. In the case, become a child of the "Category A" parent
'parent'=> term_exists( 'Category A', 'category' )['term_id']
));
wp_insert_term(
// the name of the sub-category
'Sub-category Level 2',
// the taxonomy 'category' (don't change)
'category',
array(
// what to use in the url for term archive
'slug' => 'level-2',
// link with main category. In the case, become a child of the "Category A" parent
'parent'=> term_exists( 'Sub-category Level 1', 'category' )['term_id']
));
wp_insert_term(
// the name of the sub-category
'Sub-category Level 3',
// the taxonomy 'category' (don't change)
'category',
array(
// what to use in the url for term archive
'slug' => 'level-3',
// link with main category. In the case, become a child of the "Category A" parent
'parent'=> term_exists( 'Sub-category Level 2', 'category' )['term_id']
));
любая помощь будет оценена.