Sonntag, 24. Juli 2011

WP - Custom Post Types anlegen

Um ein Custom Post Type anzlegen und eine dazugehörige Taxonomie sowie Tags füge folgenden Code in die function.php ein.

add_action('init', 'post_type_arzt');
function post_type_arzt()
{
register_post_type('arzt',
array(
'label' => __('Arzt'),
'public' => true,
'_builtin' => false,
'show_ui' => true,
'has_archive' => true,
'supports' => array('thumbnail','title','editor','excerpt','comments' ) ) );
ate

register_taxonomy( 'stichworte', 'arzt',
array(
'hierarchical' => false,
'label' => __('Stichworte'),
'query_var' => 'stichworte',
'rewrite' => array( 'slug' => 'stichworte' ) ) );

register_taxonomy( 'Stadt_kat', 'arzt',
array(
'hierarchical' => true,
'label' => __('Arztbereich-Categories'),
'singular_label' => 'Arztbereich-Category',
'rewrite' => true,
'query_var' => true) ); 
}

Um das Array des Custom Post Types zu bearbeiten, beachte welche Elemente bearbeitet werden können.

supports

(array) (optional) An alias for calling add_post_type_support() directly.
Default: title and editor
  • 'title'
  • 'editor' (content)
  • 'author'
  • 'thumbnail' (featured image, current theme must also support post-thumbnails)
  • 'excerpt'
  • 'trackbacks'
  • 'custom-fields'
  • 'comments' (also will see comment count balloon on edit screen)
  • 'revisions' (will store revisions)
  • 'page-attributes' (menu order, hierarchical must be true to show Parent option)
  • 'post-formats' add post formats, see Post Formats


Ein genaue Liste findest Du hier:
http://codex.wordpress.org/Function_Reference/register_post_type


Quelle: http://bloggonaut.net/custom-post-types-und-custom-taxonomies

Keine Kommentare:

Kommentar veröffentlichen