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

Add title should be optional #1914

Closed
ChemicalSailor opened this issue Jul 15, 2017 · 27 comments
Closed

Add title should be optional #1914

ChemicalSailor opened this issue Jul 15, 2017 · 27 comments
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Document Settings Document settings experience [Type] Enhancement A suggestion for improvement.

Comments

@ChemicalSailor
Copy link

Not all posts will have titles. A lot of my users tend to write status updates so a title isn't required. The title should really be just another block rather than it's own entity so it can at least be switched or indeed be placed below a cover image block

@westonruter
Copy link
Member

Title could be a block in the same way as excerpt (#1288) can be a block. Both would be useOnce blocks (#1661). These blocks would only be available a given post type supports title and excerpt respectively.

@braders
Copy link

braders commented Jul 16, 2017

I'm really not sure titles should be a optional, at least for now. Defining something as a block suggests something as optional, whereas a title really isn't an optional field (sure, it can be empty, but WordPress will still append protected/ private strings & themes will assume a title to exist). Additionally, titles are used to reference posts/ pages within wp-admin.

The title should really be just another block rather than it's own entity so it can at least be switched

Switched for what? The theme controls the output of the title, so I'm not sure why there are more than two options here (title or no title)

[Title] placed below a cover image block

Nice idea, but I again wonder if this should be controlled by the theme. E.g. a theme could hook into the block parsing process, in order to add the title after the first cover image (or at the start if no cover images exist). I have taken a similar approach with ACF flexible content in the past, without too much difficulty. This also has the bonus of forcing front-end consitsncy.

Leaving the title position under theme control also means legacy themes using the_title() above the_content() won't be affected.

--

That said, I do see an opportunity here. If the title was a block that could never be deleted (i.e. not optional), then it could add controls to the post setting sidebar. These could be used by themes to give various output options (above post, below cover image). Core could also have a "hide from front-end" checkbox. Then all that is needed is a new has_title() function which themes can use, possibly with a theme_supports opt-in.

I suspect this is better left until Gutenburg is more mature though - as it stands, titles are in no worse position than core is today.

@hedgefield
Copy link

Titles do not seem optional to me either - how else would you know which post is which in the posts overview? But hiding the title block seems useful. Because when I put a cover image in my post, it annoys me that the title block is still there. The whole purpose of a cover image block, it seems to me, is to jazz up a post title. A featured image and title in one, basically. What other use would the cover image be if you still have to put a regular title above it (or below it)?

Or maybe those two blocks could be merged? That's what I would prefer. Right now the title block doesn't have any properties in the inspector anyway.

@westonruter
Copy link
Member

Titles are optional, for example, in the “status” posts. Take P2/O2 as an example:

image

Behind the scenes, O2 will grab the first 5 words from the body to then use as the post title, for the purpose of post lists I think: https://github.com/Automattic/o2/blob/ee615502667df01ead93853be4f56a97f63fed3f/inc/write-api.php#L89-L95

@ChemicalSailor
Copy link
Author

Yes, titles are totally optional in WordPress currently. The first few words of the post content will be used for the post title if the user doesn't enter one. For those of us who adopted post formats (for better or worse) get by without titles on the status format.

Perhaps this is more of a design consideration at the moment. Currently it looks as though the title is part of the content within gutenberg as it shares the block design language. So one of the first things I did was tried to format it in the same way as any other block. Really it doesn't have to be part of the content, some themes may not even show it (e.g. pages, custom post types), or use it in the <head> but not in the <body>. But as pointed out it is useful as a label for 'this is what this content is'. Taking this approach then it really should be entered in a separate area as metadata.

On the other approach that 'the title is an essential piece of the content' then it should have comparable functionality to other blocks for formatting. In terms of switching, comparable ones would be text, heading and cover image. Going down this route we should be able to make some pretty good guesses as to what the title of the post is based on blocks used and how it's written.

@karmatosed
Copy link
Member

I agree that titles should be optional.

@karmatosed karmatosed added [Feature] Blocks Overall functionality of blocks [Type] Enhancement A suggestion for improvement. labels Jul 24, 2017
@ellatrix ellatrix self-assigned this Jul 28, 2017
@melchoyce
Copy link
Contributor

If I just post an image on my photoblog, it doesn't necessarily need a title. I'm also a +1 for title remaining optional.

@pento
Copy link
Member

pento commented Oct 12, 2017

A fix for this should also explicitly check if the current post type has declared that it supports titles, and hide the title block if it hasn't.

@mtias mtias added the [Feature] Document Settings Document settings experience label Nov 20, 2017
@mtias
Copy link
Member

mtias commented Nov 20, 2017

Yes, checking for the post type would be a simple update. Though it wouldn't cover cases like aside / status. This will be better once we can look beyond the post_content area so we don't have to chase what the front end might represent (which depends on the theme).

@ellatrix ellatrix removed their assignment Feb 12, 2018
@ChemicalSailor
Copy link
Author

I've been thinking a bit more about this in terms of design. Perhaps something like this would be worth a try?
screen shot 2018-02-17 at 15 45 50

Makes it a bit more obvious that the title is not the content. I'm thinking that there might then be a title block that can be inserted, which may well revert it to the current design. Just an idea so feel free to scrap it.

@karmatosed
Copy link
Member

@ChemicalSailor thanks for the exploration. I think this though only possibly works on larger screens. What would happen on smaller ones? I would caution against us adding to the top section as this mixes types. The title is linked to the content not the interactions.

@ChemicalSailor
Copy link
Author

@karmatosed thanks for your insight, I can't argue against that. Perhaps there is some compromise solution. I still think there needs to be some extra separation, at the moment the title looks like an inherent part of the content.

@karmatosed
Copy link
Member

What about if we simply add an ellipsis menu item to delete the title?

@hedgefield
Copy link

That's a great idea I think.

@mtias
Copy link
Member

mtias commented Mar 7, 2018

I wouldn't make anything custom for title until "title" is itself a block. Which seems like a task for stage 2 of Gutenberg. At that point you'd be able to move/delete the title block and combine it with post date, by-line, etc.

@jasmussen
Copy link
Contributor

It seems there's a wide agreement that we making the title a block that was, perhaps, inserted by default but removable, would be a nice enhancement.

But it's also unlikely to happen in phase 1 of Gutenberg. As such, I'm going to close this for now, we can always reopen.

@swinggraphics
Copy link

Position and display of titles are often controlled by the theme and separate from the content. Gutenberg assumes the title is part of the content and displays it that way. The title should/could just be an attribute. If my theme wants the title in the content, I will use an h1. I like the suggestion of a title block that is added by default (with that functionality being disable-able via remove_action) and is removable. If there's no title block or h1 tag, throw up a warning if the concern is that users might make poor choices if they have control over their content.

@Jonnyauk
Copy link

Add title +1 to make this easily removable PLEASE!! We build complex, bespoke themes that often have complex title options built for each project (such as 'type of title', background images, sub titles etc).

In it's current form the Gutenberg 'editor' assumes that the title is 'floating' above 'content' - so this suits basic sites, I get it. However, this doesn't suit the kind of sites that many professional agencies build - we should have the option to remove this (via code - not by a user of-course!) and dare I say a hook to insert 'above Gutenberg' so we can logically put our own 'header options' above the main editor, rather than pretty much being forced to relegate such options to the sidebar area.

I'm not bashing Gutenberg - there's a-lot I like about it (really!!), but right now this is a big blocker for us for adoption.

@swinggraphics
Copy link

There's also the simple issue of screen real estate. The title just takes up so much space in the editor. It would perhaps be best if title and slug were, optionally, a metabox.

@Jonnyauk
Copy link

Good news on this as a follow-up: see #11929

@swinggraphics
Copy link

That's quite a different issue. Many themes don't want to remove post type support for Title; they just don't want the title to be in the body of the editor.

@Jonnyauk
Copy link

@swinggraphics - hmmmm, not sure on that one buddy - maybe we are coming at this from different angles?! Correct me if I'm wrong but actually by using the code example in #11929 will achieve removal of the post title field in the post editor admin UI (in Gutenberg) - which was the original issue request.

Also, in my testing, the title isn't going into the post content on page output - it is rendering out separately as defined in my theme exactly where it should - and separate to the post content/body.

Once removed, there would be nothing stopping you creating your own block or sidebar metabox option to either add your own custom title field if required + more advanced title/header options - which is where my interest lies in this issue.

Bear in mind that remove_post_type_support() can be used on both in-built post types and custom post types too without conditional tests (first param is post type) - so VERY easy to do even for beginner developers.

@swinggraphics
Copy link

OP wanted titles optional on a per-post basis, so remove_post_type_support isn't a solution for that, either.

@goodcare
Copy link

i also think the title should be optional because of design reasons. maybe give an option to hide the title.

@braco
Copy link

braco commented Dec 9, 2018

Nice solution, @ChemicalSailor. That would be nice and makes more sense to me. Maybe it could optionally be placed near the permalink panel. As it is now, it just seems like it's irrevocably part of the page's topmost content, which isn't always the case. It might cover other use cases with a setting that allowed other blocks to come before the title.

I ended up using ACF for this:

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

function my_acf_save_post( $post_id ) {
	$my_post = array();
	$my_post['ID'] = $post_id;
	$my_post['post_title'] = get_field('title', $post_id);
	wp_update_post($my_post);
}
add_action('acf/save_post', 'my_acf_save_post', 20);

There's still the problem of h1 being blocked from the inline controls:
#4234

@jenssogaard
Copy link

This is not ideal but a fairly innocent fix. Only CSS overrides that moves the input away from the other blocks and make it visually connected to the sidebar instead:
Gutenberg Pagetitle fix

The admin styles:

.block-editor .editor-post-title {
        background: #f3f4f5;
        width: 100%;
        padding: 3.5em 2em 2em 2em;
        margin-bottom: 2em;
        border-bottom: 1px solid #e2e4e7;
}

.block-editor .editor-post-title .wp-block {
        max-width: none;
}

.edit-post-visual-editor.editor-styles-wrapper {
        padding-top: 0;
}

.wp-block.editor-post-title__block.has-fixed-toolbar:after {
        content: "Title";
        padding-left: 1em;
}

.edit-post-layout.has-fixed-toolbar .edit-post-layout__content {
        padding-top: 0;
}

@VladNov
Copy link

VladNov commented Dec 6, 2019

Title can be moved into the sidebar, above the "URL slug" field. It feels like a natural location fo the title and it will also combine it with other editor unrelated elements like Featured Image and Excerpt in posts. It would be awesome to let the blocks begin from the top, without margins or paddings, for example, for the Cover or other similar blocks usage.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Blocks Overall functionality of blocks [Feature] Document Settings Document settings experience [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests