Hier mal ein kurzer Textschnippsel für einen Custom Post Type um schön Strukturiert Bücherrezensionen zu erstellen. Wie das ganze aussieht könnt ihr euch bei Game of Books ansehen
function cptui_register_my_cpts_book() {
/**
* Post Type: Bücher-Rezensionen.
*/
$labels = array(
"name" => __( "Bücher-Rezensionen", "tiny-framework" ),
"singular_name" => __( "Buch-Rezension", "tiny-framework" ),
);
$args = array(
"label" => __( "Bücher-Rezensionen", "tiny-framework" ),
"labels" => $labels,
"description" => "",
"public" => true,
"publicly_queryable" => true,
"show_ui" => true,
"show_in_rest" => false,
"rest_base" => "",
"has_archive" => "books",
"show_in_menu" => true,
"show_in_nav_menus" => true,
"exclude_from_search" => false,
"capability_type" => "post",
"map_meta_cap" => true,
"hierarchical" => false,
"rewrite" => array( "slug" => "book", "with_front" => true ),
"query_var" => true,
"supports" => array( "title", "thumbnail", "excerpt", "trackbacks", "comments", "revisions", "author" ),
"taxonomies" => array( "category", "post_tag", "ngg_tag" ),
);
register_post_type( "book", $args );
}
add_action( 'init', 'cptui_register_my_cpts_book' );
und dann noch die dazugehörigen Custom Fields:
if(function_exists("register_field_group"))
{
register_field_group(array (
'id' => 'acf_books',
'title' => 'Books',
'fields' => array (
array (
'key' => 'field_5b560505663f5',
'label' => 'Autor',
'name' => 'autor',
'type' => 'text',
'required' => 1,
'default_value' => '',
'placeholder' => 'Nachname, Vorname',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_5b560532663f6',
'label' => 'Titel',
'name' => 'titel',
'type' => 'text',
'required' => 1,
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_5b561803a4d38',
'label' => 'Verlag',
'name' => 'verlag',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_5b561812a4d39',
'label' => 'ISBN-13',
'name' => 'isbn-13',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'none',
'maxlength' => '',
),
array (
'key' => 'field_5b5618cb79bda',
'label' => 'Quellen-Copyright:',
'name' => 'quellen-copyright',
'type' => 'text',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'formatting' => 'html',
'maxlength' => '',
),
array (
'key' => 'field_5b563a25c9ad9',
'label' => 'Galerie-ID',
'name' => 'galerieid',
'type' => 'number',
'default_value' => '',
'placeholder' => '',
'prepend' => '',
'append' => '',
'min' => '',
'max' => '',
'step' => '',
),
array (
'key' => 'field_5b5615dc5491b',
'label' => 'Einleitung:',
'name' => 'einleitung',
'type' => 'textarea',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'html',
),
array (
'key' => 'field_5b561344258de',
'label' => 'Inhalt:',
'name' => 'inhalt',
'type' => 'textarea',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'html',
),
array (
'key' => 'field_5b561383258df',
'label' => 'Meinung:',
'name' => 'meinung',
'type' => 'textarea',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'html',
),
array (
'key' => 'field_5b561396258e0',
'label' => 'Autor-Bio:',
'name' => 'autor-bio',
'type' => 'textarea',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'html',
),
array (
'key' => 'field_5b583548354ef',
'label' => 'Freitext',
'name' => 'freitext',
'type' => 'textarea',
'default_value' => '',
'placeholder' => '',
'maxlength' => '',
'rows' => '',
'formatting' => 'html',
),
),
'location' => array (
array (
array (
'param' => 'post_type',
'operator' => '==',
'value' => 'book',
'order_no' => 0,
'group_no' => 0,
),
),
),
'options' => array (
'position' => 'acf_after_title',
'layout' => 'no_box',
'hide_on_screen' => array (
),
),
'menu_order' => 0,
));
}