Opened 11 years ago
Closed 5 years ago
#26976 closed enhancement (wontfix)
WP should try to set a default title
Reported by: | Denis-de-Bernardy | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.8 |
Component: | Posts, Post Types | Keywords: | needs-patch close |
Focuses: | ui, administration, template | Cc: |
Description
When creating a post without a title, various bits and pieces of WP aren't as user-friendly as they should be.
Among them:
- Occurrences of "(no-title)" in the admin area (e.g. posts list)
- Posts titled after their ID in the Recent Posts widget
Could we add some code in there to try to fill the gaps where relevant, i.e. in cases where an author who purposely sets no title (for an aside when not using a custom post type or similar, for instance) would find it desirable and useful? Namely:
- In the admin area, for post lists
- In the RSS feed, for feed readers
- In widgets, and more generally outside of the loop
Tentative solution that can be dropped as a plugin in the meanwhile, to see what I mean:
add_filter('the_title', function($title, $post_id) { if ($title || in_the_loop() && !is_feed() && !is_admin()) return $title; $post = get_post($post_id); if (trim($post->post_excerpt)) { $text = $post->post_excerpt; $text = apply_filters('the_excerpt', $text); } else { $text = $post->post_content; $text = strip_shortcodes($text); $text = apply_filters('the_content', $text); $text = str_replace(']]>', ']]>', $text); } return wp_trim_words($text, 6); }, -50, 2);
Change History (10)
This ticket was mentioned in IRC in #wordpress-dev by Latz_. View the logs.
11 years ago
#3
in reply to:
↑ 2
@
11 years ago
- Type changed from feature request to defect (bug)
Replying to Latz:
Inserting some arbitrary text will most certainly lead to some confusions. If an author decides to have no title for his post I think he is satisfied to see "(no title)" in the backend.
The same goes for feeds. If the author sets no title he most probably wants to have no title in the feed neither. BTW, WP is handling the empty title correctly by setting the title tag to<title />
.
It would make more sense to put the proposed behaviour into a plugin since the user would consciously opt-in for this feature in that case.
I think you're missing the point of the bug report — it has nothing to do with the <title>
tag or whatever appears when outputting the title in a loop, and everything to do with the title of posts when viewed in lists.
Currently, the admin area fills in a cryptic and extremely unhelpful "(no title)". In feeds and widgets, in contrast, WP will show the post's ID — nothing else. Not "(no title)" or anything useful: a numerical ID in guise of title.
In both cases, having WP be a bit smarter by outputting the first few words gives a lot more context.
#5
follow-up:
↓ 7
@
11 years ago
I think I understood the essence of your ticket. The hint that with the <title>
tag was just to show that the devs have thought about posts with no title.
But...(!)
today I came across a problem that's related to yours. I wanted to create some pages which have parents and children. For layout reasons the main page does not have a title. When editing the children I would not have been able to find the parent page if there would have been more than one page without a title since the page was only listed as an empty line in the parent selection box.
Experiencing this I think there should be a possibility to enter an internally used name for the page.
Nevertheless I don't think that posts (and pages, too) should be titled automagically. I'm going to write a separate ticket for the page parent problem (#27218).
#6
@
11 years ago
- Component changed from General to Posts, Post Types
- Focuses accessibility removed
- Version changed from trunk to 3.8
#7
in reply to:
↑ 5
@
11 years ago
Replying to Latz:
Experiencing this I think there should be a possibility to enter an internally used name for the page.
Or, WP could generate it automatically to avoid extra UI clutter. Try the patch I posted in your setup (drop it in a mu-plugin file), to see what I mean and how it *doesn't* affect the front-end — unless you add a pages menu as well, of course, in which case you'll find it a welcome addition too.
Inserting some arbitrary text will most certainly lead to some confusions. If an author decides to have no title for his post I think he is satisfied to see "(no title)" in the backend.
The same goes for feeds. If the author sets no title he most probably wants to have no title in the feed neither. BTW, WP is handling the empty title correctly by setting the title tag to
<title />
.It would make more sense to put the proposed behaviour into a plugin since the user would consciously opt-in for this feature in that case.