Make WordPress Core

Opened 6 years ago

Last modified 2 months ago

#48122 new feature request

Add separator argument for wp_get_document_title()

Reported by: ngdangtu's profile ngdangtu 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)

general-template.php (143.2 KB) - added by ngdangtu 6 years ago.
The modified general-template.php which
ticket-48122.diff (821 bytes) - added by ngdangtu 6 years ago.

Download all attachments as: .zip

Change History (7)

@ngdangtu
6 years ago

The modified general-template.php which

#1 @SergeyBiryukov
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 @ngdangtu
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.

#3 @SergeyBiryukov
6 years ago

  • Keywords has-patch added; needs-patch removed

#4 @SergeyBiryukov
6 years ago

  • Summary changed from Improving `title-tag` to Add separator argument for wp_get_document_title()

#5 @callumbw95
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. 😃

Note: See TracTickets for help on using tickets.