Switch language
wpseek on Twitter


A WordPress-centric search engine for devs and theme authors




get_the_category [ ]

get_the_category ( $id = false )
Parameters:
  • (int) $id Optional, default to current post ID. The post ID.
Uses:
  • $post
Returns:
  • (array)
Defined at:
Codex



Retrieve post categories.

Source

function get_the_category( $id = false ) {
	$categories = get_the_terms( $id, 'category' );
	if ( ! $categories || is_wp_error( $categories ) )
		$categories = array();

	$categories = array_values( $categories );

	foreach ( array_keys( $categories ) as $key ) {
		_make_cat_compat( $categories[$key] );
	}

	/**
	 * Filter the array of categories to return for a post.
	 *
	 * @since 3.1.0
	 *
	 * @param array $categories An array of categories to return for the post.
	 */
	return apply_filters( 'get_the_categories', $categories );
}

Top Google Search Results

User Note(s)