0

I use this code to create a new custom post type, but the problem is that it shows the same categories of default posts. Is it possible have different categories for this custom post type?

function crear_tipo_agencias() {
    $labels = array(
        'name'               => _x( 'Agencias', 'Post Type General Name', 'text_domain' ),
        'singular_name'      => _x( 'Agencia', 'Post Type Singular Name', 'text_domain' ),
        'menu_name'          => __( 'Agencias', 'text_domain' ),
        'parent_item_colon'  => __( 'Agencia Padre', 'text_domain' ),
        'all_items'          => __( 'Agencias', 'text_domain' ),
        'view_item'          => __( 'Ver Agencia', 'text_domain' ),
        'add_new_item'       => __( 'Añadir Agencia Nueva', 'text_domain' ),
        'add_new'            => __( 'Añadir', 'text_domain' ),
        'edit_item'          => __( 'Editar Agencia', 'text_domain' ),
        'update_item'        => __( 'Actualizar', 'text_domain' ),
        'search_items'       => __( 'Buscar Agencias', 'text_domain' ),
        'not_found'          => __( 'Agencias no encontradas', 'text_domain' ),
        'not_found_in_trash' => __( 'Agencias no encontradas en Papelera', 'text_domain' ),
    );    
    $rewrite = array(
        'slug'                => 'agencia',
        'with_front'          => true,
        'pages'               => true,
        'feeds'               => true,
    );    
    $args = array(
        'label'               => __( 'agencia', 'text_domain' ),
        'description'         => __( 'Agencias relacionadas', 'text_domain' ),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'comments', 'thumbnail', 'custom-fields'),
        'taxonomies'          => array( 'category', 'post_tag' ),
        'hierarchical'        => false,
        'public'              => true,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'menu_position'       => 5,
        'menu_icon'           => site_url().'/wp-content/themes/Avada/images/iconnoticias.png',
        'can_export'          => true,
        'has_archive'         => 'agencias',
        'exclude_from_search' => false,
        'query_var'           => 'agencias',
        'rewrite'             => $rewrite,
        'capability_type'     => 'post',
    );    
    register_post_type('agencias', $args);
}    
add_action('init', 'crear_tipo_agencias', 0);
1

You specify supported taxonomies right there:

'taxonomies'          => array( 'category', 'post_tag' ),

If you want different set you should configure it accordingly. Possibly registering custom taxonomies if that is what needed.

  • thanks but how can use others categories then? sorry for my ignorance, i'm learning @Rarst – Vektor Unbreakable Oct 17 '14 at 15:34
  • 1
    @VektorUnbreakable I am not sure how basic you need to start "use" at. See register_taxonomy() for a start on custom taxonoimes. – Rarst Oct 17 '14 at 15:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.