Return to Snippet

Revision: 12623
at March 21, 2009 12:55 by BoNzO


Initial Code
/**
 * Ritorna la categoria padre di un post
 *
 * @return
 * @param object $post_id
 */
function get_parent_category( $post_id ) {
	$cats = wp_get_object_terms($post_id, 'category', array('fields' => 'all') );
	foreach( $cats as $key => $cat ) if( $cat->parent == 0) return $cat;
	return null;
}

Initial URL

                                

Initial Description

                                

Initial Title
Categoria padre di un post in Wordpress

Initial Tags
wordpress

Initial Language
PHP