Ich habe mir ein Benutzerdefinierten Post Typ angelegt um Flash Magazine zu verwalten.
Beim Speichern eines neuen Buches unter Add New Book wird die Kategorie beim aktualisieren nicht gespeichert.
Bei der Suche erhalte ich kein ergebniss.
Was muss ich da noch einbauen?
In der functions.php des Themplates habe ich folgenden Code eingebunden.
PHP
add_action( 'init', 'create_post_type' );
function create_post_type() {
$labels = array(
'name' => _x('Books', 'post type general name'),
'singular_name' => _x('Book', 'post type singular name'),
'add_new' => _x('Add New', 'book'),
'add_new_item' => __('Add New Book'),
'edit_item' => __('Edit Book'),
'new_item' => __('New Book'),
'view_item' => __('View Book'),
'search_items' => __('Search Books'),
'not_found' => __('No books found'),
'not_found_in_trash' => __('No books found in Trash'),
'parent_item_colon' => '',
'menu_name' => 'Books'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title','editor','author','thumbnail','excerpt','comments')
);
register_post_type('book',$args);
}
function add_console_taxonomies() {
register_taxonomy('console', 'book', array(
// Hierarchical taxonomy (like categories)
'hierarchical' => true,
// This array of options controls the labels displayed in the WordPress Admin UI
'labels' => array(
'name' => _x( 'Book Category', 'taxonomy general name' ),
'singular_name' => _x( 'Book-Category', 'taxonomy singular name' ),
'search_items' => __( 'Search Book-Categories' ),
'all_items' => __( 'All Book-Categories' ),
'parent_item' => __( 'Parent Book-Category' ),
'parent_item_colon' => __( 'Parent Book-Category:' ),
'edit_item' => __( 'Edit Book-Category' ),
'update_item' => __( 'Update Book-Category' ),
'add_new_item' => __( 'Add New Book-Category' ),
'new_item_name' => __( 'New Book-Category Name' ),
'menu_name' => __( 'Review Categories' ),
),
// Control the slugs used for this taxonomy
'rewrite' => array(
'slug' => 'console', // This controls the base slug that will display before each term
'with_front' => false, // Don't display the category base before "/locations/"
'hierarchical' => true // This will allow URL's like "/locations/boston/cambridge/"
),
));
}
add_action( 'init', 'add_console_taxonomies', 0 );
Alles anzeigen