Мне нужно показать 3 категории и 3 подкатегории для каждой категории?
Вот что я хотел бы иметь для каждой категории:
Категория А
[*]подкатегория 1
[*]подкатегория 2
[*]подкатегория 3
Я добавил следующий код в файл function.php темы WordPress:
Код: Выделить всё
//create the main category
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 1',
// the taxonomy 'category' (don't change)
'category',
array(
// what to use in the url for term archive
'slug' => 'sub-cat-1',
// link with main category. In the case, become a child of the "Category A" parent
'parent'=> term_exists( 'Category A', 'category' )['term_id']
));
Ошибка анализа: ошибка анализа, ожидание `')'' в строке 57...
Соответствует 'parent'=> term_exists( 'Category A', 'category' )['term_id'].
Что я делаю не так?
Подробнее здесь: https://stackoverflow.com/questions/386 ... mmatically
Мобильная версия