views:

18

answers:

1

I'm trying to figure out how to find a post category or tag when editing a post in wp-admin.

I need this because I want to show some modules in the editor only for a post of a certain category.

Is there a way to accomplish that result?

+1  A: 

You can use the get_the_category() function to get the categories of the current post. From the codex:

global $post;
$categories = get_the_category($post->ID);
var_dump($categories);
Kau-Boy
It works! I'm trying to figure how to do the same thing with the custom taxonomies. Normally I use the 'wp_get_object_terms' function to retreive posts custom taxonomies (wp_get_object_terms($post_id, 'taxonomy_name')) but if I call the function in the wp-admin the function give me this error: WP_Error Object ( [errors] => Array ( [invalid_taxonomy] => Array ( [0] => Invalid Taxonomy ) ) [error_data] => Array ( ) )
Pennywise83