Skip to content

Instantly share code, notes, and snippets.

@DarioBF DarioBF/CPTs 1
Last active Jan 8, 2020

Embed
What would you like to do?
add_action( 'init', 'bf_register_custom_post_type' );
/**
* Registro un custom post type 'libro'.
*
* @link http://codex.wordpress.org/Function_Reference/register_post_type
*/
function bf_register_custom_post_type() {
/* Añado las etiquetas que aparecerán en el escritorio de WordPress */
$labels = array(
'name' => _x( 'Libros', 'post type general name', 'text-domain' ),
'singular_name' => _x( 'Libro', 'post type singular name', 'text-domain' ),
'menu_name' => _x( 'Libros', 'admin menu', 'text-domain' ),
'add_new' => _x( 'Añadir nuevo', 'libro', 'text-domain' ),
'add_new_item' => __( 'Añadir nuevo libro', 'text-domain' ),
'new_item' => __( 'Nuevo libro', 'text-domain' ),
'edit_item' => __( 'Editar libro', 'text-domain' ),
'view_item' => __( 'Ver libro', 'text-domain' ),
'all_items' => __( 'Todos los libros', 'text-domain' ),
'search_items' => __( 'Buscar libros', 'text-domain' ),
'not_found' => __( 'No hay libros.', 'text-domain' ),
'not_found_in_trash' => __( 'No hay libros en la papelera.', 'text-domain' )
);
/* Configuro el comportamiento y funcionalidades del nuevo custom post type */
$args = array(
'labels' => $labels,
'description' => __( 'Descripción.', 'text-domain' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'libro' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments' )
);
register_post_type( 'libro', $args );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.