[wp-trac] [WordPress Trac] #17336: Can't use get_the_terms() within a function that hooks into publish_post

WordPress Trac wp-trac at lists.automattic.com
Thu Aug 30 00:36:45 UTC 2012


#17336: Can't use get_the_terms() within a function that hooks into publish_post
--------------------------+------------------------------
 Reporter:  defunctlife   |       Owner:
     Type:  defect (bug)  |      Status:  closed
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Taxonomy      |     Version:  3.1
 Severity:  normal        |  Resolution:  invalid
 Keywords:                |
--------------------------+------------------------------
Changes (by wonderboymusic):

 * status:  new => closed
 * resolution:   => invalid


Comment:

 I think you have some code in weird places - this works:

 {{{
 add_action( 'init', function () {
         register_taxonomy( 'custom_thing', 'post', array( 'labels' =>
 array( 'name' => 'Woo Hoo' ) ) );
 } );

 function shift_add_progress_report_notification( $post_ID ) {

         $terms = get_the_terms( $post_ID, 'custom_thing' );

         var_dump( $terms );
         exit();
 }
 add_action( 'publish_post', 'shift_add_progress_report_notification', 10,
 1 );
 }}}

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/17336#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list