theme development – Custom post type 404 category page

Question

I created a custom post type called news and a taxonomy for the custom post type called news categories. However, the category page archive returns me 404.

**Register Custom Post Type**

    $labels_noticias = array(
        'name'               => __( 'Notícias' ),
        'singular_name'      => __( 'Notícia' ),
        'add_new'            => __( 'Nova Notícia' ),
        'add_new_item'       => __( 'Nova Notícia' ),
        'edit_item'          => __( 'Editar Notícia' ),
        'new_item'           => __( 'Nova Notícia' ),
        'all_items'          => __( 'Todas as Notícias' ),
        'view_item'          => __( 'Visualizar Notícia' ),
        'search_items'       => __( 'Pesquisar Notícias' ),
        'not_found'          => __( 'Nenhuma notícia encontrada ' ),
        'not_found_in_trash' => __( 'Nenhuma notícia encontrada na lixeira ' ),
    );
    
    // Argumentos CPT Notícias
    $args_noticias = array(
        'labels'            => $labels_noticias,
        'description'       => 'Contém nossas notícias',
        'taxonomies'        => array('categoria-noticias','noticias-tag'),
        'public'            => true,
        'menu_position'     => 5,
        'menu_icon'         => 'data:image/svg+xml;base64,' . base64_encode($icons_cpt['noticias']),
        'supports'          => $supports,
        'has_archive'       => 'noticias',
        'show_in_admin_bar' => true,
        'show_in_nav_menus' => true,
        'show_in_rest'      => true,
        'query_var'         => 'noticia',
    );
    register_post_type ( 'noticias', $args_noticias );
    
** Register Custom Taxonomie **

    $labels_categories = array(
        'name'              => _x( 'Categorias', 'taxonomy general name' ),
        'singular_name'     => _x( 'Categoria', 'taxonomy singular name' ),
        'search_items'      => __( 'Buscar Categorias' ),
        'all_items'         => __( 'Todas Categorias' ),
        'parent_item'       => __( 'Categoria Pai' ),
        'parent_item_colon' => __( 'Categoria Pai:' ),
        'edit_item'         => __( 'Editar Categoria' ),
        'update_item'       => __( 'Atualizar Categoria' ),
        'add_new_item'      => __( 'Adicionar nova Categoria' ),
        'new_item_name'     => __( 'Novo nome de categoria' ),
        'menu_name'         => __( 'Categorias' ),
    );
    $args_categories   = array(
        'hierarchical'      => true, // make it hierarchical (like categories)
        'labels'            => $labels_categories,
        'show_ui'           => true,
        'show_admin_column' => true,
        'query_var'         => true,
        'rewrite'           => [ 'slug' => 'noticias' ],
    );

register_taxonomy( "categoria-noticias", $args_categories );

0
Renan Bessa 4 weeks 2021-04-14T10:35:23-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse