Alright, there’s been numerous topics about this, but it doesn’t seem to work for me.
I have one normal page, called “Resources”.
Then I have several Custom Post Types. One of which is “Video’s”.
I want “Video’s” to be a child page of “Resources”. At the moment, I can both access the video’s page by the URL: http://example.com/resources/videos AND http://example.com/videos (they both work).
My Videos CPT is as follows:
function register_custom_post_video() {
$labels = array(
'name' => _x('Videos', 'videos'),
'singular_name' => _x('Video', 'video'),
'add_new' => _x('Add New Video', 'Video'),
'add_new_item' => __('Add New Video'),
'edit_item' => __('Edit Video'),
'new_item' => __('New Video'),
'view_item' => __('View Video'),
'search_items' => __('Search Videos'),
'not_found' => __('No Videos found'),
'not_found_in_trash' => __('No Videos found in Trash'),
'parent_item_colon' => ''
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => array('slug' => 'resources', 'with_front' => true),
'capability_type' => 'page',
'hierarchical' => true,
'menu_position' => null,
'supports' => array('title','editor','author','excerpt','page-attributes')
);
register_post_type( 'videos' , $args );
}
add_action('init', 'register_custom_post_video');
But the rewrite doesn’t seem to work. Also, when I resave the permalinks settings, it doesn’t work.
I use archive-videos.php
as the page.
Also, according to a WP Tuts+ quicktip, the
Therefore, to make a hierarchical custom post type, you have to have the âpage-attributesâ set in the âsupportsâ array and the âhierarchicalâ flag set to true. I hope this was helpful to you as well!
does not work either.
Am I doing something wrong?
You need to add page-attributes to the supports array e.g.
This then should give you the parent functionality