gutenberg icon indicating copy to clipboard operation
gutenberg copied to clipboard

Remove Title from Table of Contents if Post Type does not support Titles

Open paulwilde opened this issue 8 years ago • 3 comments

#5738 removed the UI of the title itself, now it just needs to be removed from the Table of Contents.

Here is a how it displays for me, with a post type that does not support a title, note that I set the title to 'Home' prior to removing support for the title:

screen shot 2018-03-27 at 15 51 57

paulwilde avatar Mar 27 '18 14:03 paulwilde

Hi, @paulwilde I created a PR to fix this problem but in fact, while testing it I was not able to replicate the problem in master because it looks like it is not possible to retrieve the title even if it exists if the post type does not supports the title. Given that title is undefined for this cases the use of title && ( <DocumentOutlineItem, is blocking the rendering of the DocumentOutline for title. Maybe it is the way the CPT is registered would it be possible to share the CPT registration code? or to test when removing title support from the sample bellow?

function create_product_type() {
    register_post_type( 'acme_product',
        array(
			'label'  => 'Product',
            'labels' => array(
                'name' => __( 'Products' ),
                'singular_name' => __( 'Product' )
            ),
            'public' => true,
			'show_in_rest' => true,
			'supports' => array( 'editor', 'title' ),
        )
    );
}
add_action( 'init', 'create_product_type' );

Thank you for submitting the issue 👍

jorgefilipecosta avatar Mar 27 '18 16:03 jorgefilipecosta

Testing with that code works, however with my version I'm taking away title support via remove_post_type_support.

Sorry, I should have clarified that I'm removing the title from the core page post type. Try the following to replicate the issue:

add_action( 'init', function() {
    remove_post_type_support( 'page', 'title' );
} );

paulwilde avatar Mar 27 '18 16:03 paulwilde

Thank you for the clarification @paulwilde, the PR https://github.com/WordPress/gutenberg/pull/5818 should handle this case.

jorgefilipecosta avatar Mar 27 '18 17:03 jorgefilipecosta