我的自定義帖子有一些分類問題。它顯示了我所有的自定義信息完美的,當我打電話url/team
,但是當我想打電話例如,「勞動」一類頁狀url/team/labor
中,我得到一個404未在前端顯示自定義類別的Wordpress自定義帖子類型
這裏是定製後的註冊在我的插件文件類型和分類:
$labels = array(
'name' => 'Team',
'singular_name' => 'Team-Mitglied',
'add_new' => 'Neues Team-Mitglied',
'add_new_item' => 'Hinzufügen',
'edit_item' => 'Team-Mitglied bearbeiten',
'new_item' => 'Neues Team-Mitglied',
'all_items' => 'Alle Team-Mitglieder',
'view_item' => 'Team-Mitglied anzeigen',
'search_items' => 'Team-Mitglied suchen',
'not_found' => 'Team-Mitglied nicht gefunden',
'not_found_in_trash' => 'Team-Mitglied nicht im Papierkorb gefunden',
'parent_item_colon' => '',
'menu_name' => 'Team',
);
$args = array(
'labels' => $labels,
'description' => 'Team-Mitglieder erstellen und verwalten',
'hierarchical' => true,
'supports' => array('title', 'thumbnail','editor'),
'public' => true,
'show_ui' => true,
'menu_position' => 25,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'publicly_queryable' => true,
'exclude_from_search' => true,
'has_archive' => true,
'query_var' => true,
'can_export' => true,
'rewrite' => true,
'capability_type' => 'post',
'menu_icon' => plugins_url('../img/icon.png',__FILE__),
'has_archive' => true,
'rewrite' => array('slug' => 'team')
);
register_post_type('team_manager', $args);
flush_rewrite_rules(); // renew the rewrite rules
//register custom category for the team manager
$labels = array(
'name' => 'Abteilungen',
'singular_name' => 'Abteilung',
'search_items' => 'Abteilung suchen',
'popular_items' => 'Beliebteste Abteilungen',
'all_items' => 'Alle Abteilungen',
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => 'Abteilung bearbeiten',
'update_item' => 'Abteilung aktualisieren',
'add_new_item' => 'Neue Abteilung',
'new_item_name' => 'Neuer Abteilungsname',
'separate_items_with_commas' => 'Abteilungen durch Komma trennen',
'add_or_remove_items' => 'Abteilungen hinzufügen oder entfernen',
'choose_from_most_used' => 'Aus den meist genutzten Abteilungen wählen',
'not_found' => 'Keine Abteilung gefunden',
'menu_name' => 'Abteilungen',
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array('slug' => 'abteilungen')
);
register_taxonomy('team_groups', 'team_manager', $args);
這是我archive-team_manager.php
部分:
$the_query = new WP_Query(array(
'post_type' => 'team_manager',
'tax_query' => array(
'taxonomy' => 'team_groups',
),
'nopaging' => true,
));
if ($the_query->have_posts()) : ?>
<?php
while ($the_query->have_posts()) { ?>
<div class="team-member">
<?php $the_query->the_post(); ?>
<div class="team-member-pic">
<?php echo get_the_post_thumbnail($post_id, 'full', array('class' => 'alignleft')); ?>
</div><!-- END .team-member-pic -->
<div class="team-member-meta">
<?php
$prename = get_post_meta(get_the_ID(), 'td-staff-prename', true);
if(! empty($prename)) {
echo '<span class="team-member-prename">' . $prename . '</span><br />';
}
$name = get_post_meta(get_the_ID(), 'td-staff-name', true);
if(! empty($name)) {
echo '<span class="team-member-name">' . $name . '</span>';
}
$td_staff_function = get_post_meta(get_the_ID(), 'td-staff-function', true);
if(! empty($td_staff_function)) {
echo '<p class="team-member-function">' . $td_staff_function . '</p>';
}?>
</div><!-- END .team-member-meta -->
<div class="team-member-desc">
<?php
$td_staff_job_training = get_post_meta(get_the_ID(), 'td-staff-job-training', true);
if(! empty($td_staff_job_training)) {
echo "<p><strong>Berufsausbildung:</strong> " . $td_staff_job_training . "</p>";
}?>
<?php
$td_staff_service_area = get_post_meta(get_the_ID(), 'td-staff-service-area', true);
if(! empty($td_staff_service_area)) {
echo "<p><strong>Arbeitsbereich:</strong> " . $td_staff_service_area . "</p>";
}?>
<?php
$td_staff_employment_since = get_post_meta(get_the_ID(), 'td-staff-employment-since', true);
if(! empty($td_staff_employment_since)) {
echo "<p><strong>Beschäftigt seit:</strong> " . $td_staff_employment_since . "</p>";
}?>
<?php
$td_staff_birthday = get_post_meta(get_the_ID(), 'td-staff-birthday', true);
if(! empty($td_staff_birthday)) {
echo "<p><strong>Geburtsdatum:</strong> " . $td_staff_birthday . "</p>";
}?>
</div><!-- END .team-member-desc -->
</div><!-- END .team-member -->
<?php
}
else :
get_template_part('/partials/content', 'not-found');
endif;
我用taxonomy.php
試了一下,但那不起作用。我閱讀了關於這個的所有wordpress-codex,但我真的很奇怪爲什麼它不起作用!我需要一個像這樣的URL結構爲我的自定義類別檔案:
'網址/ team`(全部來自我的自定義後類型職位)* *做
`網址/團隊/ labor`(所有的從我的自定義後後輸入一個特定的自定義類別)* 404 *錯誤
最後,我希望你們對我有一點點線索:)
爲什麼你要調用分類?你想列出一個頁面中的所有分類或額外的東西嗎? – 2014-09-24 06:30:12
Hallo Arshad,我需要在檔案中顯示自定義類別,以便我可以顯示由類別表示的部門中的工作人員。 – TobiD 2014-09-24 10:19:50