Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

CPT serveis

CPT per serveis

if ( ! function_exists('cpt_serveis') ) {

// Register Custom Post Type
function cpt_serveis() {

	$labels = array(
		'name'                  => _x( 'Serveis', 'Post Type General Name', 'text_domain' ),
		'singular_name'         => _x( 'Servei', 'Post Type Singular Name', 'text_domain' ),
		'menu_name'             => __( 'Serveis', 'text_domain' ),
		'name_admin_bar'        => __( 'Serveis', 'text_domain' ),
		'archives'              => __( 'Archius de serveis', 'text_domain' ),
		'attributes'            => __( 'Atributs de servei', 'text_domain' ),
		'parent_item_colon'     => __( 'Servei superior', 'text_domain' ),
		'all_items'             => __( 'Tots els serveis', 'text_domain' ),
		'add_new_item'          => __( 'Afegir nou servei', 'text_domain' ),
		'add_new'               => __( 'Afegir nou', 'text_domain' ),
		'new_item'              => __( 'Nou servei', 'text_domain' ),
		'edit_item'             => __( 'Editar servei', 'text_domain' ),
		'update_item'           => __( 'Actualitzar servei', 'text_domain' ),
		'view_item'             => __( 'Veure servei', 'text_domain' ),
		'view_items'            => __( 'Veure serveis', 'text_domain' ),
		'search_items'          => __( 'Cercar servei', 'text_domain' ),
		'not_found'             => __( 'No trobat', 'text_domain' ),
		'not_found_in_trash'    => __( 'No trobat en la paperera', 'text_domain' ),
		'featured_image'        => __( 'Imatge destacada', 'text_domain' ),
		'set_featured_image'    => __( 'Establir imatge destacada', 'text_domain' ),
		'remove_featured_image' => __( 'Eliminar imatge destacada', 'text_domain' ),
		'use_featured_image'    => __( 'Usar com a imatge destacada', 'text_domain' ),
		'insert_into_item'      => __( 'Inserir en el servei', 'text_domain' ),
		'uploaded_to_this_item' => __( 'Actualitzar en aquest servei', 'text_domain' ),
		'items_list'            => __( 'Llista de serveis', 'text_domain' ),
		'items_list_navigation' => __( 'Llista de navegaciò de serveis', 'text_domain' ),
		'filter_items_list'     => __( 'Filtrar la llista de serveis', 'text_domain' ),
	);
	$rewrite = array(
		'slug'                  => 'servei',
		'with_front'            => true,
		'pages'                 => true,
		'feeds'                 => true,
	);
	$args = array(
		'label'                 => __( 'Servei', 'text_domain' ),
		'description'           => __( 'CPT per a serveis', 'text_domain' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'post-formats' ),
		'taxonomies'            => array( 'category', 'post_tag' ),
		'hierarchical'          => false,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 5,
		'menu_icon'             => 'dashicons-list-view',
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => 'servei',
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'rewrite'               => $rewrite,
		'capability_type'       => 'page',
		'show_in_rest'          => true,
	);
	register_post_type( 'serveis', $args );

}
add_action( 'init', 'cpt_serveis', 0 );

}