Ticket #5746 (new enhancement)

Opened 5 months ago

Last modified 4 months ago

Add id of the post to the 'the_post' filter

Reported by: henrikmelin Assigned to: anonymous
Priority: normal Milestone: 2.6
Component: General Version: 2.3.2
Severity: normal Keywords: 2nd-opinion has-patch
Cc: henrikmelin

Description

When the id of a post is specified in get_the_title($id), it is not always possible to get the ID of the post in the 'the_title' filter, since the post is not necessarily held in $post. For a good example of this see the' Activity Box' on the Dashboard.

One reason one would want the id is to modify the title with, e.g. values held in custom fields.

I propose that the id is passed as an argument to the 'the_title' filter as follows:

function get_the_title($id = 0) {

... return apply_filters( 'the_title', $title, $post->ID );

}

Which would always make the (correct) id available to the filter.

Cheers, Henrik.

Attachments

5746.diff (494 bytes) - added by DD32 on 02/12/08 03:29:09.
Make it so.

Change History

02/11/08 20:36:28 changed by lloydbudd

  • milestone set to 2.6.

02/12/08 03:29:09 changed by DD32

  • attachment 5746.diff added.

Make it so.

02/12/08 03:30:50 changed by DD32

  • keywords changed from 2nd-opinion to 2nd-opinion has-patch.
  • milestone changed from 2.6 to 2.5.

I can see that for some people, It'd be good to know which post title the filter is modifing, so i've made a patch.

03/14/08 09:20:00 changed by Denis-de-Bernardy

Imho, the same could be said for the_content, the_excerpt, and other post-related filters.

Then again, get_the_ID() can return the ID while in the loop, and this is good enough as far as I can tell.

03/20/08 00:04:13 changed by ffemtcj

  • milestone changed from 2.5 to 2.6.