Make WordPress Core

Opened 5 years ago

Last modified 5 years 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
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 5 years ago.
The modified general-template.php which
ticket-48122.diff (821 bytes) - added by ngdangtu 5 years ago.

Download all attachments as: .zip

Change History (6)

@ngdangtu
5 years ago

The modified general-template.php which

#1 @SergeyBiryukov
5 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
5 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
5 years ago

  • Keywords has-patch added; needs-patch removed

#4 @SergeyBiryukov
5 years ago

  • Summary changed from Improving `title-tag` to Add separator argument for wp_get_document_title()
Note: See TracTickets for help on using tickets.