Opened 6 years ago
Last modified 2 months ago
#48122 new feature request
Add separator argument for wp_get_document_title()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Awaiting Review | Priority: | normal |
| Severity: | normal | Version: | |
| Component: | Themes | Keywords: | dev-feedback has-patch close |
| Focuses: | ui, template | Cc: |
Description
As far as I know, there is an official way to customize WordPress title-tag support. And my suggestion that we should allow devs change separator of title-tag. So, I decided to modify lines: (the lines' position is a bit relative)
1027 : Add a new argument ($separator) with '-' as default value which allow to change $sep variable.
1116 : Replace value '-' with $separator.
1151 : Add a new argument ($sep) with '-' as default value. This will allow devs add their own separator through hook.
1156 : Pass $sep to wp_get_document_title() function.
Attachments (2)
Change History (7)
#1
@
6 years ago
- Component changed from Customize to Themes
- Keywords needs-patch added; needs-testing removed
Hi @ngdangtu, welcome to WordPress Trac! Thanks for the report.
Could you create a patch with your suggested improvements?
Check out https://make.wordpress.org/core/handbook/tutorials/trac/submitting-a-patch/ and https://make.wordpress.org/core/handbook/tutorials/working-with-patches/ to learn more about creating patches.
#2
@
6 years ago
Add a ticket patch.
This patch reduces modification from 4 lines to 2 lines (remove changing line 1151 and 1156) since _wp_render_title_tag() is a private function.
I suggest the new argument because it might be useful for meta title or to display in other position of web which might need a few modification while calling wp_get_document_title(). I hope this suggestion is useful to other devs.
#4
@
6 years ago
- Summary changed from Improving `title-tag` to Add separator argument for wp_get_document_title()
#5
@
2 months ago
- Keywords close added
Hi @ngdangtu,
I have taken a look into this, and it looks like the separator variable $sep now has a filter attached to it's value document_title_separator. This feels like it should be enough to achieve the same functionality as what your suggested parameter was originally set to achieve. As of such I feel like we can close this ticket now, and have provisionally attached the close tag. Please feel free to remove this tag if you feel otherwise. 😃
The modified general-template.php which