I am trying to create a custom post type called DondeAmigo that accepts hierarchical pages. Example: I create a page called 'lewis', whose URL becomes: /donde-amigo/lewis. Then, I create a page called 'home' that I want it to be under 'lewis'. The idea would be for the URL to be /donde-amigo/lewis/home .
I set hierarchical
to true
and I added 'page-attributes'
inside 'supports'
. But still, when I edit the new page, I do not see the 'Add parent page' option.
//WHERE IS OUR FRIEND?
$labels = array(
'name' => _x( 'DondeAmigo', 'post type general name' ),
'singular_name' => _x( 'dondeamigo', 'post type singular name' ),
'add_new' => _x( 'Añadir nueva', 'book' ),
'add_new_item' => __( 'Añadir nueva página' ),
'edit_item' => __( 'Editar página' ),
'new_item' => __( 'Nueva página' ),
'view_item' => __( 'Ver página' ),
'search_items' => __( 'Buscar página' ),
'not_found' => __( 'No se han encontrado página' ),
'not_found_in_trash' => __( 'No se han encontrado páginas en la papelera' ),
'parent_item_colon' => ''
);
// Creamos un array para $args
$args = array( 'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'taxonomies' => array('dondeamigo'),
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => null,
'show_in_rest' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields','page-attributes')
);
register_post_type( 'donde-amigo', $args );
I am trying to create a custom post type called DondeAmigo that accepts hierarchical pages. Example: I create a page called 'lewis', whose URL becomes: /donde-amigo/lewis. Then, I create a page called 'home' that I want it to be under 'lewis'. The idea would be for the URL to be /donde-amigo/lewis/home .
I set hierarchical
to true
and I added 'page-attributes'
inside 'supports'
. But still, when I edit the new page, I do not see the 'Add parent page' option.
//WHERE IS OUR FRIEND?
$labels = array(
'name' => _x( 'DondeAmigo', 'post type general name' ),
'singular_name' => _x( 'dondeamigo', 'post type singular name' ),
'add_new' => _x( 'Añadir nueva', 'book' ),
'add_new_item' => __( 'Añadir nueva página' ),
'edit_item' => __( 'Editar página' ),
'new_item' => __( 'Nueva página' ),
'view_item' => __( 'Ver página' ),
'search_items' => __( 'Buscar página' ),
'not_found' => __( 'No se han encontrado página' ),
'not_found_in_trash' => __( 'No se han encontrado páginas en la papelera' ),
'parent_item_colon' => ''
);
// Creamos un array para $args
$args = array( 'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'taxonomies' => array('dondeamigo'),
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => null,
'show_in_rest' => true,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields','page-attributes')
);
register_post_type( 'donde-amigo', $args );
Share
Improve this question
asked Jan 9, 2021 at 12:10
Luis GaldoLuis Galdo
1012 bronze badges
3
- Are there more than 1 pages - you can't have a parent until you have 2 pages? also, did you try 'capability_type' => 'page', – Q Studio Commented Jan 9, 2021 at 12:29
- Yes, I already have 4 pages created, but when adding a new one, no option for it being the child of one of the others. – Luis Galdo Commented Jan 9, 2021 at 13:00
- Also, I tried 'capability_type' => 'page' and nothing – Luis Galdo Commented Jan 9, 2021 at 13:02
1 Answer
Reset to default 0I discovered that if you press fast_edit
before editing the page, there is an option to choose the superior page. While if you access edit
this option is not present.
The reason might be a collision between plugins or between a plugin and WordPress.