Skip to content

Instantly share code, notes, and snippets.

@joseconti
Last active March 25, 2018 22:09
Show Gist options
  • Save joseconti/482bebdeb3a2358e7d9c6c8fc421b53d to your computer and use it in GitHub Desktop.
Save joseconti/482bebdeb3a2358e7d9c6c8fc421b53d to your computer and use it in GitHub Desktop.
<?php
// Register Custom Post Type
function ejemplo_custom_post_type() {
$labels = array(
'name' => _x( 'Post Types', 'Post Type General Name', 'dominio_traduccion' ),
'singular_name' => _x( 'Post Type', 'Post Type Singular Name', 'dominio_traduccion' ),
'menu_name' => __( 'Post Types', 'dominio_traduccion' ),
'name_admin_bar' => __( 'Post Type', 'dominio_traduccion' ),
'archives' => __( 'Item Archives', 'dominio_traduccion' ),
'attributes' => __( 'Item Attributes', 'dominio_traduccion' ),
'parent_item_colon' => __( 'Parent Item:', 'dominio_traduccion' ),
'all_items' => __( 'All Items', 'dominio_traduccion' ),
'add_new_item' => __( 'Add New Item', 'dominio_traduccion' ),
'add_new' => __( 'Add New', 'dominio_traduccion' ),
'new_item' => __( 'New Item', 'dominio_traduccion' ),
'edit_item' => __( 'Edit Item', 'dominio_traduccion' ),
'update_item' => __( 'Update Item', 'dominio_traduccion' ),
'view_item' => __( 'View Item', 'dominio_traduccion' ),
'view_items' => __( 'View Items', 'dominio_traduccion' ),
'search_items' => __( 'Search Item', 'dominio_traduccion' ),
'not_found' => __( 'Not found', 'dominio_traduccion' ),
'not_found_in_trash' => __( 'Not found in Trash', 'dominio_traduccion' ),
'featured_image' => __( 'Featured Image', 'dominio_traduccion' ),
'set_featured_image' => __( 'Set featured image', 'dominio_traduccion' ),
'remove_featured_image' => __( 'Remove featured image', 'dominio_traduccion' ),
'use_featured_image' => __( 'Use as featured image', 'dominio_traduccion' ),
'insert_into_item' => __( 'Insert into item', 'dominio_traduccion' ),
'uploaded_to_this_item' => __( 'Uploaded to this item', 'dominio_traduccion' ),
'items_list' => __( 'Items list', 'dominio_traduccion' ),
'items_list_navigation' => __( 'Items list navigation', 'dominio_traduccion' ),
'filter_items_list' => __( 'Filter items list', 'dominio_traduccion' ),
);
$args = array(
'label' => __( 'Post Type', 'dominio_traduccion' ),
'description' => __( 'Descripción Post Personalizado', 'dominio_traduccion' ),
'labels' => $labels,
'supports' => array( 'title', 'editor' ),
'taxonomies' => array( 'category', 'post_tag' ),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => false, // Esta opción a false para esconderlo en el menú de WordPress
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => true,
'capability_type' => 'page',
);
register_post_type( 'post_personalizado', $args );
}
add_action( 'init', 'ejemplo_custom_post_type', 0 );
// la siguiente línea deberemos añadirla a nuestra función de creación de menú y añadida a la acción addmin_menu > add_action('admin_menu', 'mi_menu');
add_submenu_page( $menu_slug, __( 'Nombre del Custom Post Type', 'dominio_traduccion' ), __( 'Nombre del Custom Post Type', 'dominio_traduccion' ), 'edit_posts', 'edit.php?post_type=post_personalizado');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment