-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcustom-post-type.php
More file actions
69 lines (53 loc) · 1.95 KB
/
custom-post-type.php
File metadata and controls
69 lines (53 loc) · 1.95 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/*
Plugin Name: WP Custom post type
Plugin URI: https://github.com/Pacomarchante/WP-Custom-post-type
Description: Ejemplo de Custom post type para WordPress.
Author: Paco Marchante
Author URI: https://github.com/Pacomarchante/
Version: 1.0.0
License: GPLv2 or later.
License URI: https://www.gnu.org/licenses/gpl-2.0.html
*/
/**
* WP Custom post type
*
* @since 1.0.0
*
* Creación del Custom post type
* Codex WordPress: https://codex.wordpress.org/Post_Types
* Ayuda para generar Custom post type: https://generatewp.com/post-type/
*/
add_action( "init" , "pc_cpt_ejemplo" );
function pc_cpt_ejemplo()
{
register_post_type( "ejemplos", // Identificador del Custom post type
[
"labels" => [
"name" => __( "Ejemplos" , "ejemplo"),
"singular_name" => __( "Ejemplo" , "ejemplo"),
],
"public" => true,
"has_archive" => true,
"menu_icon" => "dashicons-images-alt",
"supports" => array( "title" , "thumbnail" , "excerpt" , "editor" ), // Codex WordPress: https://codex.wordpress.org/Function_Reference/post_type_supports
"rewrite" => array( "slug" => "ejemplos-wordpress" ),
]
);
}
/**
* WP Custom post type
*
* @since 1.0.0
*
* Esta función permite cambiar el texto del placeholder que aparece en el título de la entrada personalizada.
*
*/
add_filter( "enter_title_here" , "pc_cpt_ejemplos_placeholder_titulo" );
function pc_cpt_ejemplos_placeholder_titulo( $title ){
$screen = get_current_screen();
if ( "ejemplos" == $screen->post_type ) { // Cambiar "ejemplos" por el identificador que elijamos para nuestro Custom post type
$title = __( "Nombre del ejemplo" , "ejemplo" );
}
return $title;
}