#23254 closed defect (bug) (fixed)
Empty Page Title Not Handled in Menu System
Reported by: | cais | Owned by: | markjaquith |
---|---|---|---|
Milestone: | 3.6 | Priority: | normal |
Severity: | normal | Version: | 3.0 |
Component: | Menus | Keywords: | has-patch commit |
Focuses: | Cc: |
Description
I noticed some peculiar menu layouts and sorted it out to having some pages with no titles (not sure the actual use case for a page without a title but it is in my test environments).
The Walker class is recognizing the page exists and creating an appropriate <a href=...>
wrapper for it but with no Page Title it is not being displayed. If this is by design I think it should be revisited and if this is a defect then the included patch (not very pretty) may offer a possible solution or at least a consideration.
The patch checks if the Page Title is empty and if it is uses the Page ID as the title.
Attachments (4)
Change History (17)
#2
follow-up:
↓ 13
@
12 years ago
- Cc DrewAPicture added
- Milestone changed from Awaiting Review to 3.6
You can probably boil down the value passed to the filter into a single variable. Something like:
$page_title = empty( $page->post_title ) ? __( 'Page-' ) . $page->ID : $page->post_title;
In trying to reproduce from the standpoint of the menu editor, there are additional issues when working with pages sans-title, namely:
- Title-less pages added to a menu hold a temporary title of '(Pending)' and the item is dropped completely on save
- We should really have some kind of title in the metabox list instead of a naked checkbox
#5
@
11 years ago
Instead of 'Page-{ID}'
, we could probably use the existing '(no title)'
string we already use in wp_ajax_find_posts()
and _draft_or_post_title()
:
tags/3.5.1/wp-admin/includes/ajax-actions.php#L1444
tags/3.5.1/wp-admin/includes/template.php#L1309
#7
@
11 years ago
23254.patch handles an empty title in the metabox too, which solves the issues outlined in comment:2.
#9
@
11 years ago
The reason why I suggested using the Page ID was as a reference to the page in question ... could/should we consider a filter for (each instance?) that text string as part of this ticket?
#10
@
11 years ago
Each instance can be filtered using existing filters: wp_setup_nav_menu_item
in wp_setup_nav_menu_item()
and the_title
in Walker_Page
:
tags/3.5.1/wp-includes/nav-menu.php#L667
tags/3.5.1/wp-includes/post-template.php#L1051
23254.2.patch adds the page/item ID.
#11
@
11 years ago
I like the new patch with the page/item ID; and, thanks for pointing out those filters.
Although I do find the first one to be rather complicated at first glance while the second seems to make sense and appears to be more direct in its affect. I was thinking something more along the lines of using the same filter hook for all instances but if two are required to address the same output text then that is what we will have to work with.
This is affecting $wp_version = '3.6-alpha-23288' as well.