Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #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?

    #431363

    Sorry to bump, but I still haven’t been able to figure this one out

    #431377

    Hey!

    Do you mind creating a temporary admin login and posting it here privately so we can look into it?

    Best regards,
    Yigit

    #431418
    This reply has been marked as private.
    #432079

    Hey!

    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,
    Ismael

    #432096

    Hi 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.
    #432619
    This reply has been marked as private.
    #432650
    This reply has been marked as private.
    #432786

    Hey!

    Thank you for coming back.

    I set the last post to private.

    Cheers!
    Günter

Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.