我正在做一个custom theme 对于a network of sites 部署在WordPress MultiSite installation.
在这些主题中,我创建了4个custom post types 它们都添加了两个分类法。第一种分类法是post_tag
其中一个是自定义分类法,类似于category
一
我已经选择了我所有的4个custom post types 拥有他们自己的分类类别,因为我不想要任何类别bleed 在post类型中。
这是我的代码:
<?php
function o_post_types()
{
$post_types = array(
\'articole\' => array(
\'name\' => \'Articole\',
\'single\' => \'Articol\',
\'icon\' => \'dashicons-admin-post\'
),
\'evenimente\' => array(
\'name\' => \'Evenimente\',
\'single\' => \'Eveniment\',
\'icon\' => \'dashicons-video-alt\'
),
\'concursuri\' => array(
\'name\' => \'Concursuri\',
\'single\' => \'Concurs\',
\'icon\' => \'dashicons-awards\'
),
\'fotografii\' => array(
\'name\' => \'Fotografii\',
\'single\' => \'Fotografie\',
\'icon\' => \'dashicons-format-image\'
),
\'promotii\' => array(
\'name\' => \'Promoții\',
\'single\' => \'Promoție\',
\'icon\' => \'dashicons-share\'
)
);
foreach ($post_types as $post_type) {
$icon = $post_type[\'icon\'];
$name_lower = strtolower($post_type[\'name\']);
$single_lower = strtolower($post_type[\'single\']);
if ($post_type[\'name\'] == \'Promoții\') {
$name_lower = \'promotii\';
$single_lower = \'promotie\';
}
$labels = array(
\'name\' => $post_type[\'name\'],
\'singular_name\' => $post_type[\'single\'],
\'add_new\' => \'Adaugă \' . $single_lower,
\'add_new_item\' => \'Adaugă \' . $single_lower . \' nou\',
\'edit_item\' => \'Editează \' . $single_lower,
\'new_item\' => $post_type[\'single\'] . \' nou\',
\'all_items\' => \'Listă \' . $name_lower,
\'view_item\' => \'Afișează \' . $single_lower,
\'search_items\' => \'Caută în \' . $name_lower,
\'not_found\' => \'Nici un \' . $single_lower . \' găsit.\',
\'not_found_in_trash\' => \'Nici un \' . $single_lower . \' găsit în Gunoi.\',
\'parent_item_colon\' => \'\',
\'menu_name\' => $post_type[\'name\']
);
$args = array(
\'labels\' => $labels,
\'public\' => true,
\'publicly_queryable\' => true,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'query_var\' => true,
\'rewrite\' => array(\'slug\' => $name_lower, \'with_front\' => false),
\'capability_type\' => \'post\',
\'has_archive\' => true,
\'hierarchical\' => false,
\'menu_position\' => 5,
\'supports\' => array(\'title\', \'editor\', \'author\', \'thumbnail\', \'excerpt\', \'comments\'),
\'taxonomies\' => array(\'post_tag\'),
\'menu_icon\' => $icon
);
register_post_type("cpt_" . $single_lower, $args);
$labels = array(
\'name\' => \'Categorii\',
\'singular_name\' => \'Categorie\',
\'search_items\' => \'Caută Categorii\',
\'all_items\' => \'Toate Categoriile\',
\'parent_item\' => \'Categorie Părinte\',
\'parent_item_colon\' => \'Categorie Părinte:\',
\'edit_item\' => \'Modifică Categorie\',
\'update_item\' => \'Actualizează Categorie\',
\'add_new_item\' => \'Adaugă Categorie nouă\',
\'new_item_name\' => \'Numele noii categorii\',
\'menu_name\' => \'Categorii\',
);
$args = array(
\'hierarchical\' => true,
\'labels\' => $labels,
\'show_ui\' => true,
\'show_admin_column\' => true,
\'query_var\' => true,
\'rewrite\' => array(
\'hierarchical\' => true,
\'slug\' => $name_lower,
\'with_front\' => false
),
);
register_taxonomy("tax_" . $name_lower, "cpt_" . $single_lower, $args);
}
}
EDIT 1*
文件名如下:
taxonomy-articole.php
taxonomy-concursuri.php
taxonomy-evenimente.php
taxonomy-fotografii.php
taxonomy-promotii.php
我正在尝试将列表显示为
category view 其中
cpt
有那个术语的。例:a
cpt_evenimente
(或
cpt_events
将有一个
tax_evenimente
term (或
tax_events
英语)如是:
滑板公园滑板秀cpt
将分配室外活动term
因为它在taxonomy-evenimente.php
环
问题是没有加载每个分类法的模板。有什么可以做的?