0
X
Add Snippet To Project
New Project
Add To Existing Project
<?php
/**
* Plugin Name: WP Turbo Custom Post Type
* Description: Erstellt einen benutzerdefinierten Post-Typ für Projekte
* Version: 1.0
* Author: WP Turbo
* Author URI: https://wpturbo.dev
* Text Domain: wpturbo
*/
// Registriere den benutzerdefinierten Post-Typ 'Projekte'
function wpturbo_register_project_post_type() {
$labels = array(
'name' => __( 'Projekte', 'wpturbo' ), // Label für den Post-Typ in der Mehrzahl
'singular_name' => __( 'Projekt', 'wpturbo' ), // Label für den Post-Typ in der Einzahl
);
$args = array(
'labels' => $labels,
'public' => true, // Öffentlich zugänglicher Post-Typ
'has_archive' => true, // Post-Typ hat ein Archiv
'show_in_rest' => true, // Zeige den Post-Typ im REST API
'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields' ), // Unterstützte Funktionen für den Post-Typ
'menu_position' => 5, // Position des Menüeintrags im Admin-Bereich
'menu_icon' => 'dashicons-portfolio', // Icon für den Menüeintrage des Post-Typs
);
register_post_type( 'project', $args ); // Registriere den Post-Typ 'project' mit den angegebenen Argumenten
}
add_action( 'init', 'wpturbo_register_project_post_type' ); // Füge die Funktion zur Initialisierung des Post-Typs hinzu
// Aktualisiere den Namen des Projekte-Menüs im Admin-Bereich
function wpturbo_update_menu_name() {
global $menu;
foreach ( $menu as $key => $item ) {
if ( 'edit.php?post_type=project' == $item[2] ) { // Überprüfe, ob der Menüeintrag den Post-Typ 'project' repräsentiert
$menu[$key][0] = __( 'Ecit Projekte', 'wpturbo' ); // Aktualisiere den Namen des Menüeintrags
break;
}
}
}
add_action( 'admin_menu', 'wpturbo_update_menu_name' ); // Füge die Funktion zur Aktualisierung des Menünamens hinzu
In this updated code, I have added comments to explain the purpose of each section. These comments provide a brief explanation of what each function or code block does. They can serve as a helpful reference for understanding and maintaining the code in the future.