get_category_to_edit

Definition:
function get_category_to_edit( $id ) {}

Parameters

  • unknown_type $id

Source code

function get_category_to_edit( $id ) {

	$category = get_category( $id, OBJECT, 'edit' );

	return $category;

}

1260

get_category_template

Definition:
function get_category_template() {}

Retrieve path of category template in current or parent template.
Works by first retrieving the current slug for example ‘category-default.php’ and then trying category ID, for example ‘category-1.php’ and will finally fallback to category.php template, if those files don’t exist.

Source code

function get_category_template() {

	$category = get_queried_object();



	$templates = array();



	$templates[] = "category-{$category->slug}.php";

1258

get_category_rss_link

Definition:
function get_category_rss_link($echo = false, $cat_ID = 1) {}

Print/Return link to category RSS2 feed.

Parameters

  • bool $echo
  • int $cat_ID

Source code

function get_category_rss_link($echo = false, $cat_ID = 1) {

	_deprecated_function( __FUNCTION__, '2.5', 'get_category_feed_link()' );



	$link = get_category_feed_link($cat_ID, 'rss2');



	if ( $echo )

		echo $link;

	return $link;

}

1256

get_category_parents

Definition:
function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() {}

Retrieve category parents with separator.

Parameters

  • int $id: Category ID.
  • bool $link: Optional, default is false. Whether to format with link.
  • string $separator: Optional, default is ‘/’. How to separate categories.
  • bool $nicename: Optional, default is false. Whether to use nice name for display.
  • array $visited: Optional. Already linked to categories to prevent duplicates.

Source code

function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) {

	$chain = '';

	$parent = &get_category( $id );

	if ( is_wp_error( $parent ) )

		return $parent;



	if ( $nicename )

		$name = $parent->slug;

	else

		$name = $parent->name;



	if ( $parent->parent && ( $parent->parent != $parent->term_id ) && !in_array( $parent->parent, $visited ) ) {

		$visited[] = $parent->parent;

		$chain .= get_category_parents( $parent->parent, $link, $separator, $nicename, $visited );

	}



	if ( $link )

		$chain .= '<a href="' . get_category_link( $parent->term_id ) . '" title="' . esc_attr( sprintf( __( "View all posts in %s" ), $parent->name ) ) . '">'.$name.'</a>' . $separator;

	else

		$chain .= $name.$separator;

	return $chain;

}

1254

get_category_link

Definition:
function get_category_link( $category ) {}

Retrieve category link URL.

Parameters

  • int|object $category: Category ID or object.

Return values

returns:Link on success, empty string if category does not exist.

Source code

function get_category_link( $category ) {

	if ( ! is_object( $category ) )

		$category = (int) $category;



	$category = get_term_link( $category, 'category' );



	if ( is_wp_error( $category ) )

		return '';



	return $category;

}

1252