Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress 5 – Register new post type in an own plugin
<?php
/**
* Plugin Name: WH Custom Post Type
*/
function add_wh_events() {
$labels = array(
'name' => 'Veranstaltungen',
'singular_name' => 'Veranstaltung',
'add_new' => 'Erstellen',
'add_new_item' => 'Neue Veranstaltung erzeugen',
'edit_item' => 'Veranstaltung bearbeiten',
'new_item' => 'Neue Veranstaltung',
'view_item' => 'Veranstaltung ansehen',
'view_items' => 'Veranstaltungen ansehen',
'search_items' => 'Nach Veranstaltungen suchen',
'not_found' => 'Nichts gefunden',
'not_found_in_trash' => 'Nichts im Papierkorb gefunden',
'all_items' => 'Alle Veranstaltungen',
'archives' => 'Veranstaltungsarchiv',
'attributes' => 'Veranstaltungsattribute',
'insert_into_item' => 'Einfügen',
'uploaded_to_this_item' => 'Medien für Veranstaltungen',
'featured_image' => 'Veranstaltungs-Flyer',
'set_featured_image' => 'Veranstaltungs-Flyer festlegen',
'remove_featured_image' => 'Veranstaltungs-Flyer entfernen',
'use_featured_image' => 'Veranstaltungs-Flyer verwenden',
'menu_name' => 'Veranstaltungen',
'filter_items_list' => 'Veranstaltungen',
'items_list_navigation' => 'Veranstaltungen',
'items_list' => 'Weitere Veranstaltungen',
'name_admin_bar' => 'Veranstaltung',
);
$args = array(
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail', 'comments', 'trackbacks', ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_in_rest' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_nav_menus' => true,
'show_in_admin_bar' => true,
'menu_position' => 5,
'can_export' => false,
'has_archive' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'rewrite' => array('slug' => 'veranstaltung'),
'capability_type' => 'page',
);
register_post_type( 'wh_event', $args );
}
add_action( 'init', 'add_wh_events', 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.