Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Snippets de código

if ( ! function_exists('awo_cpt_codigo') ) {

// Register Custom Post Type
function awo_cpt_codigo() {

	$labels = array(
		'name'                  => _x( 'Snippets', 'Post Type General Name', 'awo' ),
		'singular_name'         => _x( 'Snippet', 'Post Type Singular Name', 'awo' ),
		'menu_name'             => __( 'Snippets', 'awo' ),
		'name_admin_bar'        => __( 'Snippet', 'awo' ),
		'archives'              => __( 'Snippets de código', 'awo' ),
		'attributes'            => __( 'Atributos del snippet', 'awo' ),
		'parent_item_colon'     => __( 'Snippet superior', 'awo' ),
		'all_items'             => __( 'Todos los snippets', 'awo' ),
		'add_new_item'          => __( 'Añadir nuevo snippet', 'awo' ),
		'add_new'               => __( 'Añadir nuevo', 'awo' ),
		'new_item'              => __( 'Nievo snippet', 'awo' ),
		'edit_item'             => __( 'Editar snippet', 'awo' ),
		'update_item'           => __( 'Actualizar snippet', 'awo' ),
		'view_item'             => __( 'Ver snippet', 'awo' ),
		'view_items'            => __( 'Ver snippets', 'awo' ),
		'search_items'          => __( 'Buscar snippet', 'awo' ),
		'not_found'             => __( 'No encontrado', 'awo' ),
		'not_found_in_trash'    => __( 'No se encuentra en la papelera', 'awo' ),
		'featured_image'        => __( 'Imagen destacada', 'awo' ),
		'set_featured_image'    => __( 'Establecer imagen destacada', 'awo' ),
		'remove_featured_image' => __( 'Eliminar imagen destacada', 'awo' ),
		'use_featured_image'    => __( 'Usar como imagen destacada', 'awo' ),
		'insert_into_item'      => __( 'Insertar en el snippet', 'awo' ),
		'uploaded_to_this_item' => __( 'Subida a este snippet', 'awo' ),
		'items_list'            => __( 'Lista de snippets', 'awo' ),
		'items_list_navigation' => __( 'Lista de navegación de snippets', 'awo' ),
		'filter_items_list'     => __( 'Filtrar lista de snippets', 'awo' ),
	);
	$rewrite = array(
		'slug'                  => 'codigo',
		'with_front'            => true,
		'pages'                 => true,
		'feeds'                 => true,
	);
	$args = array(
		'label'                 => __( 'Snippet', 'awo' ),
		'description'           => __( 'Este plugin registra un nuevo CPT llamado Snippet', 'awo' ),
		'labels'                => $labels,
		'supports'              => array( 'title', 'editor', 'thumbnail', 'page-attributes' ),
		'taxonomies'            => array( 'category', 'lenguaje' ),
		'hierarchical'          => false,
		'public'                => true,
		'show_ui'               => true,
		'show_in_menu'          => true,
		'menu_position'         => 5,
		'menu_icon'             => 'dashicons-editor-code',
		'show_in_admin_bar'     => true,
		'show_in_nav_menus'     => true,
		'can_export'            => true,
		'has_archive'           => true,
		'exclude_from_search'   => false,
		'publicly_queryable'    => true,
		'rewrite'               => $rewrite,
		'capability_type'       => 'post',
		'show_in_rest'          => true,
	);
	register_post_type( 'snippet', $args );

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

}