[wp-trac] [WordPress Trac] #49805: missing get_the_title / confusing the_title filter
WordPress Trac
noreply at wordpress.org
Sat Apr 4 13:35:50 UTC 2020
#49805: missing get_the_title / confusing the_title filter
--------------------------+------------------------------
Reporter: thomask | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version: trunk
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by roytanck):
Hi Thomask. I'm trying to understand what you are trying to achieve here.
As far as I know, the `the_title` filter hook is meant to filter the
textual content of the title, not to add markup. The template function
`the_title()` is a wrapper around `get_the_title()`, so it makes sense to
place the filter inside the latter.
The `the_title` function also has "before" and "after" parameters,
allowing theme authors to wrap the title in markup.
If there was a `the_title_wrap` filter, its results would -in many themes
- land inside an `<h1>` element, or even possibly in the header title tag.
I don't see a way to add a hook to safely wrap the title in markup, given
in how many places `the_title()` and `get_the_title()` are potentially
used.
As for `the_content`, that hook filters the post content, which obviously
is already a piece of HTML markup that you can safely extend with more
markup.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/49805#comment:1>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list