Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#35253 closed defect (bug) (invalid)

The codex says the_title filter is deprecated

Reported by: steve@… Owned by:
Priority: normal Milestone:
Component: General Version: 4.4
Severity: normal Keywords:
Cc: Focuses:

Description (last modified by SergeyBiryukov)

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 );

Change History (4)

#1 @swissspidy
11 years ago

  • Milestone Awaiting Review
  • Resolutioninvalid
  • Status newclosed

Hi there

Thanks for your report and welcome to trac.

The codex entry is wrong. The the_title filter is not deprecated. In fact, there's currently not even a way to deprecate filters.

It looks like the person who added that note mixed something up.

If you're unsure about a Codex entry, have a look at the code reference. There you can see if something is really deprecated or not.

Ps. If you find misleading information on the codex (e.g. when the information isn't the same as in the code reference), you can also go ahead and just edit it.

#2 follow-up: @chacha102
11 years ago

@swissspidy I will say that the code reference definitely makes it looks like the_title is deprecated, even though it is just looking at its uses in deprecated.php. We might want to ping meta and see if there is a way to fix that.


#3 @SergeyBiryukov
11 years ago

  • Description modified (diff)

#4 in reply to: ↑ 2 @SergeyBiryukov
11 years ago

Replying to chacha102:

I will say that the code reference definitely makes it looks like the_title is deprecated, even though it is just looking at its uses in deprecated.php. We might want to ping meta and see if there is a way to fix that.

See #meta1085.

Note: See TracTickets for help on using tickets.