Hi @Rodrigo Pontremoli:
I am finding that with the following code in my theme's functions.php
file that wp_get_object_terms($post->ID,'page-type',array('orderby' => 'none'))
is in fact working in my theme's page.php
template file:
add_action('init','page_terms_init');
function page_terms_init() {
register_taxonomy('page-type', 'page', array(
'hierarchical' => true,
'label' => 'Page Type',
'query_var' => 'page-type',
'rewrite' => array('slug'=>'page-types' ),
)
);
// This should really be done in a plugin activation
global $wp_rewrite;
$wp_rewrite->flush_rules(false);
}
So, I figure there are one of two things happening:
It is working for you but the format of the return values are not what you expect, or
You have a plugin that is causing it to fail.
When you are calling wp_get_object_terms()
that $post
doesn't have a value.
If it is #1 then this is what my test data looks like:
Array
(
[0] => stdClass Object
(
[term_id] => 140
[name] => info
[slug] => info
[term_group] => 0
[term_taxonomy_id] => 146
[taxonomy] => page-type
[description] =>
[parent] => 0
[count] => 1
)
[1] => stdClass Object
(
[term_id] => 141
[name] => pics
[slug] => pics
[term_group] => 0
[term_taxonomy_id] => 147
[taxonomy] => page-type
[description] =>
[parent] => 0
[count] => 1
)
[2] => stdClass Object
(
[term_id] => 142
[name] => vids
[slug] => vids
[term_group] => 0
[term_taxonomy_id] => 148
[taxonomy] => page-type
[description] =>
[parent] => 0
[count] => 1
)
[3] => stdClass Object
(
[term_id] => 143
[name] => Flickr
[slug] => flickr
[term_group] => 0
[term_taxonomy_id] => 149
[taxonomy] => page-type
[description] =>
[parent] => 141
[count] => 1
)
[4] => stdClass Object
(
[term_id] => 144
[name] => Other
[slug] => other
[term_group] => 0
[term_taxonomy_id] => 150
[taxonomy] => page-type
[description] =>
[parent] => 141
[count] => 1
)
[5] => stdClass Object
(
[term_id] => 145
[name] => Youtube
[slug] => youtube
[term_group] => 0
[term_taxonomy_id] => 151
[taxonomy] => page-type
[description] =>
[parent] => 142
[count] => 1
)
[6] => stdClass Object
(
[term_id] => 146
[name] => Other
[slug] => other-vids
[term_group] => 0
[term_taxonomy_id] => 152
[taxonomy] => page-type
[description] =>
[parent] => 142
[count] => 1
)
)
If it is #2 then try disabling your plugins one-by-one until you find the culprit.
If #3 then you'll need to move your code to where $post->ID
does have a value.