我有一個自定義的帖子類型包括我使用。這大致包括這樣的東西:
你可能會創建一些$ types數組,可以幫助你完成你所需要的。
<?php
// ADDING CUSTOM POST TYPE
add_action('init', 'all_custom_post_types');
function all_custom_post_types() {
$types = array(
// Student
array('the_type' => 'students',
'single' => 'Student',
'plural' => 'Students',
'hierarchical' => true,
'support' => array('title','editor','thumbnail','custom-fields'),
'taxonomy' => array('')),
// Teacher1
array('the_type' => 'teacher1',
'single' => 'Teacher1',
'plural' => 'Teachers1',
'hierarchical' => true,
'support' => array('title','editor','thumbnail','custom-fields'),
'taxonomy' => array('')),
// Teacher2
array('the_type' => 'teacher2',
'single' => 'Teacher2',
'plural' => 'Teachers2',
'hierarchical' => true,
'support' => array('title','editor','thumbnail','custom-fields'),
'taxonomy' => array('')),
// Teacher3
array('the_type' => 'teacher3',
'single' => 'Teacher3',
'plural' => 'Teachers3',
'hierarchical' => true,
'support' => array('title','editor','thumbnail','custom-fields'),
'taxonomy' => array('')),
// Family and Friends - not sure if this is 2 or 1 category - but you get the idea by now.
array('the_type' => 'family-and-friends',
'single' => 'Family and Friends',
'plural' => 'Family and Friends',
'hierarchical' => true,
'support' => array('title','editor','thumbnail','custom-fields'),
'taxonomy' => array(''))
);
foreach ($types as $type) {
$the_type = $type['the_type'];
$single = $type['single'];
$plural = $type['plural'];
$labels = array(
'name' => _x($plural, 'post type general name'),
'singular_name' => _x($single, 'post type singular name'),
'add_new' => _x('Add New', $single),
'add_new_item' => __('Add New '. $single),
'edit_item' => __('Edit '.$single),
'new_item' => __('New '.$single),
'view_item' => __('View '.$single),
'search_items' => __('Search '.$plural),
'not_found' => __('No '.$plural.' found'),
'not_found_in_trash' => __('No '.$plural.' found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true, // $rewriter,
'capability_type' => 'post',
'hierarchical' => $type['hierarchical'],
'menu_position' => 5,
'supports' => $type['support']
);
register_post_type($the_type, $args);
}
}
?>
我已經修改了$類型數組爲你 - 如果你需要調整它希望你瞭解如何從這個。如果沒有,我可能需要更多的信息。
如果您的問題在標題中,您的問題將會更加成功。例如:我如何製作動態命名的WordPress自定義文章類型?此外,WordPress的堆棧交換可能與您的興趣相關。 http://wordpress.stackexchange.com/ – DingoEatingFuzz 2012-04-02 00:26:14