Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
paulwilde opened this issue Mar 27, 2018 · 3 comments
Closed
Assignees

Comments

@paulwilde
Copy link
Contributor

#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

@jorgefilipecosta
Copy link
Member

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 👍

@paulwilde
Copy link
Contributor Author

paulwilde commented Mar 27, 2018

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' );
} );

@jorgefilipecosta
Copy link
Member

Thank you for the clarification @paulwilde, the PR #5818 should handle this case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants