You can do the following. Create two post-types photo and video. For each a different taxonomy photo_cat and video_cat. Now build two arrays, one with taxonomies and one with a list of cities:
$termsArray = array( 'photo_cat ', 'video_cat' );
$startArray = array(
'mos' => 'Москва',
'len' => 'Санкт-Петербург',
'nsk' => 'Новосибирск',
'ekb' => 'Екатеринбург',
);
Now you can cycle to create them foreach ( $startArray as $key => $startItem ) {
foreach ( $termsArray as $termsItem ) {
// Проверяем, что такого термина еще не существует
$termID = get_term_by( 'slug', $key, $termsItem )->term_id ?: '0';
if ( $termID == '0' ) {
$termArgs = array(
'cat_ID' => $termID,
'cat_name' => $startItem,
'category_description' => '',
'category_nicename' => $key,
'category_parent' => '',
'taxonomy' => $termsItem
);
$termID = wp_insert_category( $termArgs );
// пишем ошибку/ успех
if( is_wp_error($termID) ) {
var_dump('Ошибка инсерта термина ' . $startItem . ' таксономии ' . $termsItem . ': ' . $termID->get_error_message())
} else {
var_dump('Термин ' . $startItem . ' таксономии ' . $termsItem . ' опубликован удачно!');
}
} // end if $termID == '0'
} // end foreach $termsArray
} // end foreach $startArray
The advantage of this method is that when you are on a page with one taxonomy you can get the posts of the other, because you know the current slang of the taxonomy To make a shared archive 'Photographers', specify the 'has_archive' argument. To make the taxonomy in breadcrumbs, you need to write the rules for link rewrite in the 'rewrite' argument