-
AuthorPosts
-
April 19, 2015 at 10:19 pm #430987
I have a custom post type called “Places”. When adding a place you can choose another place to be its parent. Currently, a place has up to 2 children, e.g. England > Shropshire > Bridgnorth. However, in the breadcrumbs it’s showing as “Home / Places / Bridgnorth” instead of “Home / Places / England / Shropshire / Bridgnorth”
Any ideas?
April 20, 2015 at 4:02 pm #431363Sorry to bump, but I still haven’t been able to figure this one out
April 20, 2015 at 4:12 pm #431377Hey!
Do you mind creating a temporary admin login and posting it here privately so we can look into it?
Best regards,
YigitApril 20, 2015 at 4:53 pm #431418This reply has been marked as private.April 21, 2015 at 3:50 pm #432079Hey!
How did you assign the parent attribute? Posts or custom post types doesn’t support hierarchy structure, only pages can be organized in a hierarchical structure. I’m sorry but I don’t think this is possible.
Regards,
IsmaelApril 21, 2015 at 4:07 pm #432096Hi Ismael,
Thanks for getting back to me.
I thought the same thing as you at first, but it is actually possible for custom post types to support hierarchy, see the definition below (note the “‘hierarchical’ => true,” setting):
function rmv_places() { $labels = array( 'name' => _x( 'Places', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'Place', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'Places', 'text_domain' ), 'parent_item_colon' => __( 'Parent Place:', 'text_domain' ), 'all_items' => __( 'All Places', 'text_domain' ), 'view_item' => __( 'View Place', 'text_domain' ), 'add_new_item' => __( 'Add New Place', 'text_domain' ), 'add_new' => __( 'Add New', 'text_domain' ), 'edit_item' => __( 'Edit Place', 'text_domain' ), 'update_item' => __( 'Update Place', 'text_domain' ), 'search_items' => __( 'Search Places', 'text_domain' ), 'not_found' => __( 'Not found', 'text_domain' ), 'not_found_in_trash' => __( 'Not found in Trash', 'text_domain' ), ); $rewrite = array( 'slug' => 'places', 'with_front' => true, 'pages' => true, 'feeds' => true, ); $args = array( 'label' => __( 'places', 'text_domain' ), 'description' => __( 'Places in the UK', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'custom-fields', 'page-attributes' ), 'taxonomies' => array( 'category' ), 'hierarchical' => true, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_nav_menus' => true, 'show_in_admin_bar' => true, 'menu_position' => 6, 'can_export' => true, 'has_archive' => true, 'exclude_from_search' => false, 'publicly_queryable' => true, 'rewrite' => $rewrite, 'capability_type' => 'page', ); register_post_type( 'places', $args ); }
- This reply was modified 9 years, 8 months ago by scottybowl.
April 22, 2015 at 8:38 am #432619April 22, 2015 at 9:50 am #432650This reply has been marked as private.April 22, 2015 at 2:15 pm #432786 -
AuthorPosts
- You must be logged in to reply to this topic.