1

I´m new in Stackexchange and my English is very bad but i will try explain myself as best I can.

I´m creating in wordpress a new web page and i need to get this urls structure with Custom post type and taxonomies:

My CPT is => cpt_noticias with rewrite slug = 'blog' My CUSTOM Taxonomy is => category_cpt_noticias with rewrite slug = 'blog'


Well! This is the structure that i need

mydomain.com/blog => ARCHIVE BLOG

mydomain.com/blog/name-taxonomy => ARCHIVE taxonomy

mydomain.com/blog/slug-post => single page of custom post type


My problem is that when I go to "mydomain.com/blog/slug-post" this return an error 404. I don`t know the cause of this.

Can you help me please? :)


My code of custom post type is here:

// creating (registering) the custom type 
register_post_type( 'cpt_noticias', /* (http://codex.wordpress.org/Function_Reference/register_post_type) */

    // let's now add all the options for this post type
    array( 'labels' => array(
            'name' => __( 'Blog', 'pew' ), 
            /* This is the Title of the Group */

            'singular_name' => __( 'Noticia', 'pew' ), 
            /* This is the individual type */

            'all_items' => __( 'Todos los Noticias', 'pew' ), 
            /* the all items menu item */

            'add_new' => __( 'Añadir nuevo', 'pew' ), 
            /* The add new menu item */

            'add_new_item' => __( 'Añadir nuevo Noticia', 'pew' ), 
            /* Añadir nuevo Display Title */

            'edit' => __( 'Editar', 'pew' ), 
            /* Edit Dialog */

            'edit_item' => __( 'Editar Noticias', 'pew' ), 
            /* Edit Display Title */

            'new_item' => __( 'Nuevo/a Noticia', 'pew' ), 
            /* New Display Title */

            'view_item' => __( 'View Noticia', 'pew' ), 
            /* View Display Title */

            'search_items' => __( 'Buscar Noticia', 'pew' ), 
            /* Search Custom Type Title */ 

            'not_found' =>  __( 'No se han encontrado Noticias en la base de datos.', 'pew' ), 
            /* This displays if there are no entries yet */ 

            'not_found_in_trash' => __( 'No hay Noticias en la papelera', 'pew' ), 
            /* This displays if there is nothing in the trash */

            'parent_item_colon' => ''
        ), 


        'description'               => __( 'Esto es un ejemplo de Noticia', 'pew' ), /* Custom Type Description */
        'public'                    => true,
        'publicly_queryable'        => true,
        'exclude_from_search'       => false,
        'show_ui'                   => true,
        'query_var'                 => true,
        'menu_position'             => 5, /* this is what order you want it to appear in on the left hand side menu */ 
        'menu_icon'                 => 'dashicons-format-aside', /* the icon for the custom post type menu */
        'capability_type'           => 'page',
        'rewrite'                   => array( 'slug' => 'blogj', 'with_front' => true ),  
        'has_archive'               => true, /* you can rename the slug here */
        'hierarchical'              => true,
        'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'trackbacks', 'custom-fields', 'comments', 'revisions', 'sticky')

    )
);

flush_rewrite_rules();
register_taxonomy_for_object_type( 'category_cpt_noticias', 'cpt_noticias' );

register_taxonomy( 'category_cpt_noticias', 
    array('cpt_noticias'), /* if you change the name of register_post_type( 'custom_type', then you have to change this */
    array(
        'labels' => array(
            'name' => __( 'Categorías de noticias', 'pew' ), /* name of the custom taxonomy */
            'singular_name' => __( 'Categoría de noticia', 'pew' ), /* single taxonomy name */
            'search_items' =>  __( 'Buscar Categorías de noticias', 'pew' ), /* search title for taxomony */
            'all_items' => __( 'Todas Categorías de noticias', 'pew' ), /* all title for taxonomies */
            'parent_item' => __( 'Padre Categorías de noticias', 'pew' ), /* parent title for taxonomy */
            'parent_item_colon' => __( 'Padre Categorías de noticias:', 'pew' ), /* parent taxonomy title */
            'edit_item' => __( 'Editar Categorías de noticias', 'pew' ), /* edit custom taxonomy title */
            'update_item' => __( 'Crear Categoría de noticia', 'pew' ), /* update title for taxonomy */
            'add_new_item' => __( 'Añadir nuevo Categoría de noticia', 'pew' ), /* Añadir nuevo title for taxonomy */
            'new_item_name' => __( 'Nuevo/a Categoría de noticia', 'pew' ) /* name title for taxonomy */
        ),
        'public'             => true,
        'hierarchical'       => false,
        'show_ui'            => true,
        'query_var'          => true,
        'show_admin_column'  => false,
        'show_in_rest'       => true,
        'rest_base'          => '',
        'show_in_quick_edit' => false,
        'rewrite' => array( 
          'slug'                => 'blogj', 
          'with_front'          => true,
          'has_archive'         => false,
          'hierarchical'        => true,
        ),

    )
);

add_action( 'init', 'custom_post_cpt_noticias');

Your Answer

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

Browse other questions tagged or ask your own question.