WordPress at a glance

get_category_by_slug() WP 1.0

Retrieve category object by category slug.

Возвращает

Object/false. Category data object on success, false if not found.

1 time = 0.000684s = slow | 50000 times = 18.52s = slow | PHP 7.0.2, WP 4.4.2

No Hooks.

Usage

get_category_by_slug( $slug );
$slug(string) (required)
The category slug.

Список изменений

С версии 2.3.0 Введена.

Code of get_category_by_slug() WP 5.5.1

wp-includes/category.php
<?php
function get_category_by_slug( $slug ) {
	$category = get_term_by( 'slug', $slug, 'category' );

	if ( $category ) {
		_make_cat_compat( $category );
	}

	return $category;
}

Related Functions

From category: Categories

No comments
    Log In . Register