eliminar el tipo de publicación personalizada Permalink

11

He registrado el tipo de publicación con lo siguiente -

$holidayLabels = array(
    'name' => __( 'Holidays'),
    'singular_name' => __( 'Holidays'),
    'all_items' => __( 'All Holidays'),
    'add_new' => __( 'Add New Holiday'),
    'add_new_item' => __( 'Add New Holiday'),
    'edit_item' => __( 'Edit Holiday'),
    'new_item' => __( 'New Holiday'),
    'view_item' => __( 'View Holidays'),
    'not_found' => __( 'No Holidays found'),
    'not_found_in_trash' => __( 'No Holidays found in Trash'),
    'parent_item_colon' => ''

);

$holidayArgs = array(
    'labels'               => $holidayLabels,
    'public'               => true,
    'publicly_queryable'   => true,
    '_builtin'             => false,
    'show_ui'              => true,
    'query_var'            => true,
    'rewrite'              => array( "slug" => "holidays" ),
    'capability_type'      => 'post',
    'hierarchical'         => false,
    //'menu_position'        => 6,
    'supports'             => array( 'title'),
    'has_archive'          => false,
    'show_in_nav_menus'    => false,

);
register_post_type('holidays', $holidayArgs);

Y quiero eliminar el enlace permanente que aparece debajo del título cuando publico un nuevo día festivo o comienzo a editar uno existente.

Quiero eliminar esto porque, los días festivos se mostrarán en un widget separado. No quiero que el administrador pueda verlo como una sola publicación de todos modos. No hay una plantilla definida para tal.

    
pregunta SachinGutte 01.08.2013 - 20:16

3 respuestas

34

Bueno, hay otra manera. Y mejor, supongo.

Debería consultar los parámetros register_post_type . Probablemente debería configurarlos de esta manera:

'public' => false,  // it's not public, it shouldn't have it's own permalink, and so on
'publicly_queryable' => true,  // you should be able to query it
'show_ui' => true,  // you should be able to edit it in wp-admin
'exclude_from_search' => true,  // you should exclude it from search results
'show_in_nav_menus' => false,  // you shouldn't be able to add it to menus
'has_archive' => false,  // it shouldn't have archive page
'rewrite' => false,  // it shouldn't have rewrite rules

Si el tipo de publicación no es público, no verá esta parte del editor.

    
respondido por el Krzysiek Dróżdż 01.08.2013 - 21:05
1

Bueno, una forma rápida sería simplemente ocultar el div contenedor usando CSS.

add_action('admin_head', 'wpds_custom_admin_post_css');
function wpds_custom_admin_post_css() {

    global $post_type;

    if ($post_type == 'post_type') {
        echo "<style>#edit-slug-box {display:none;}</style>";
    }
}
    
respondido por el M-R 01.08.2013 - 20:38
0

También puedes ocultar esta área colocando un pequeño código de JavaScript en admin_footer hook.

<?php
add_action('admin_footer', function() {
  global $post_type;
  if ($post_type == 'your_post_type') {
    echo '<script> document.getElementById("edit-slug-box").outerHTML = ""; 
    </script>';
  });
}
    
respondido por el Eh Jewel 24.07.2018 - 13:07

Lea otras preguntas en las etiquetas