[wp-trac] [WordPress Trac] #17037: get_the_title() will pass an empty title and invalid post ID to 'the_title' filter on invalid post ID

WordPress Trac wp-trac at lists.automattic.com
Sun Apr 3 19:25:53 UTC 2011


#17037: get_the_title() will pass an empty title and invalid post ID to 'the_title'
filter on invalid post ID
--------------------------+-----------------------------
 Reporter:  kawauso       |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Template      |    Version:  3.1
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 `get_the_title()` has a workaround for when an invalid post ID is passed,
 setting the title to an empty string and post ID to the requested ID, then
 passing this to 'the_title' filter.

 '''Example:'''
 {{{
 function testme() {
         var_dump( get_the_title( 99999 ) );
 }

 function filterme( $title ) {
         return "[$title]";
 }

 add_action( 'wp_head', 'testme' );
 add_filter( 'the_title', 'filterme' );
 }}}

 Is there a reason for this odd functionality?

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17037>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list