0
X
Add Snippet To Project
New Project
Add To Existing Project
<?php
/**
* Plugin Name: WP Plugin
* Plugin URI: https://example.com
* Description: This is a custom WordPress plugin.
* Version: 1.0.0
* Author: WP Turbo
* Author URI: https://wpturbo.dev
* Text Domain: wpturbo
*/
// Register custom post type
function wpturbo_register_eventi_post_type() {
$labels = array(
'name' => __( 'Eventi', 'wpturbo' ),
'singular_name' => __( 'Event', 'wpturbo' ),
'menu_name' => __( 'Eventi', 'wpturbo' ),
'add_new' => __( 'Add New', 'wpturbo' ),
'add_new_item' => __( 'Add New Event', 'wpturbo' ),
'edit' => __( 'Edit', 'wpturbo' ),
'edit_item' => __( 'Edit Event', 'wpturbo' ),
'new_item' => __( 'New Event', 'wpturbo' ),
'view' => __( 'View', 'wpturbo' ),
'view_item' => __( 'View Event', 'wpturbo' ),
'search_items' => __( 'Search Events', 'wpturbo' ),
'not_found' => __( 'No events found', 'wpturbo' ),
'not_found_in_trash' => __( 'No events found in trash', 'wpturbo' ),
'parent' => __( 'Parent Event', 'wpturbo' ),
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'eventi' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt' ),
);
$result = register_post_type( 'eventi', $args );
if ( is_wp_error( $result ) ) {
// Log or display the error message
$error_message = $result->get_error_message();
error_log( 'Eventi Post Type Registration Error: ' . $error_message );
}
}
add_action( 'init', 'wpturbo_register_eventi_post_type' );