Last active
February 18, 2020 18:12
-
-
Save WordPress-Handbuch/a116119c4fec918cfebe66fd9f7349ce to your computer and use it in GitHub Desktop.
WordPress 5 – Register new post type in an own plugin
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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
:) Thnx a lot, such great infos and stuff to read and learn in your book!