[wp-trac] [WordPress Trac] #39129: get_the_terms seems to be broken after upgrading to version 4.7

WordPress Trac noreply at wordpress.org
Wed Dec 7 02:45:17 UTC 2016


#39129: get_the_terms seems to be broken after upgrading to version 4.7
-------------------------------------+------------------------------
 Reporter:  kuphd1                   |       Owner:
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  Taxonomy                 |     Version:  4.7
 Severity:  major                    |  Resolution:
 Keywords:  reporter-feedback close  |     Focuses:
-------------------------------------+------------------------------

Comment (by kuphd1):

 Hi @dd32,

 Here is how the taxonomy is registered:

 {{{#!php
 <?php

 // Chapters Taxonomy
 add_action('init', 'cptui_register_my_taxes_states');
 function cptui_register_my_taxes_states() {
 register_taxonomy( 'states',array (
 0 => 'chapters',
 ),
 array( 'hierarchical' => true,
 'label' => 'States',
 'show_ui' => true,
 'query_var' => true,
 'show_admin_column' => false,
 'labels' => array (
 'search_items' => 'State',
 'popular_items' => 'Popular States',
 'all_items' => 'All States',
 'parent_item' => 'Parent State',
 'parent_item_colon' => 'Parent State:',
 'edit_item' => 'Edit State',
 'update_item' => 'Update State',
 'add_new_item' => 'Add New State',
 'new_item_name' => 'New State Name',
 'separate_items_with_commas' => 'Separate states with commas',
 'add_or_remove_items' => 'Add or remove states',
 'choose_from_most_used' => 'Choose from the most used states',
 )
 ) );
 }
 ?>
 }}}

 When I run this:

 {{{#!php
 <?php
 $terms_test = get_the_terms($post->ID, 'states');
 print_r($terms_test);
 ?>
 }}}

 ...it's empty which is why I'm getting the foreach error.

 Hope that helps.

 Thanks.

--
Ticket URL: <https://core.trac.wordpress.org/ticket/39129#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list