[wp-trac] [WordPress Trac] #35253: The codex says the_title filter is deprecated
WordPress Trac
noreply at wordpress.org
Tue Dec 29 15:14:01 UTC 2015
#35253: The codex says the_title filter is deprecated
--------------------------+----------------------
Reporter: steve@… | Owner:
Type: defect (bug) | Status: closed
Priority: normal | Milestone:
Component: General | Version: 4.4
Severity: normal | Resolution: invalid
Keywords: | Focuses:
--------------------------+----------------------
Description changed by SergeyBiryukov:
Old description:
> the_title filter is marked as deprecated in 4.4 on
> https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title
>
> The replacements suggested also change the <title> tag. I'm using
> the_title filter to modify the page's title ("entry title"), not the
> title tag with the code below. If one does not use the_title, then there
> does not seem to be a way to change the post title without changing the
> <title> tag, too.
>
> So, is there a better filter or is this mis-marked in the codex as
> deprecated?
>
> function jspr_headline( $title, $id) {
> if ( is_page( $id) && $field = get_field('page_headline') ) {
> return $field;
> } else {
> return $title;
> }
> }
> add_filter( 'the_title', 'jspr_headline', 10, 2 );
New description:
the_title filter is marked as deprecated in 4.4 on
https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title
The replacements suggested also change the <title> tag. I'm using
the_title filter to modify the page's title ("entry title"), not the title
tag with the code below. If one does not use the_title, then there does
not seem to be a way to change the post title without changing the <title>
tag, too.
So, is there a better filter or is this mis-marked in the codex as
deprecated?
{{{
function jspr_headline( $title, $id) {
if ( is_page( $id) && $field = get_field('page_headline') ) {
return $field;
} else {
return $title;
}
}
add_filter( 'the_title', 'jspr_headline', 10, 2 );
}}}
--
--
Ticket URL: <https://core.trac.wordpress.org/ticket/35253#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list