Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

ko:Function Reference/get category

This page redirects to an external site: https://developer.wordpress.org/reference/functions/get_category/

함수 설명

주어진 카테고리 ID 또는 카테고리 객체를 가지고 카테고리 데이터를 반환합니다.

만약 $category 매개변수에 객체를 넘기면 데이터베이스로부터 반환된 카테고리 row 객체일 것입니다.

만약 $category 매개변수에 카테고리 ID(정수)를 넘기면 데이터베이스로부터 반환된 카테고리일 것입니다. if it isn't already cached, and pass it back.

get_term()을 보면, 두 타입 모두 $filter 매개변수값을 기반으로 몇몇 필터를 거쳐 가공됩니다.

The category will converted to maintain backwards compatibility.

참고: 카테고리 ID를 근거로 카테고리 링크를 얻으려면 get_term() 을 사용하세요. get_category는 오직 포스트 타입의 카테고리만 반환합니다.

사용 방법

<?php get_category$category$output$filter ?>

매개변수

$category
(integer|object) (required) 카테고리 ID 또는 카테고리 row 객체
Default: None
$output
(string) (optional) Constant OBJECT, ARRAY_A, 또는 ARRAY_N
Default: OBJECT
$filter
(string) (optional) Default is raw or no WordPress defined filter will applied.
Default: 'raw'

반환 값

(mixed) 
$output 매개변수에 정의한 타입의 카테고리 데이터. $category 가 존재하지 않는 카테고리 ID라면 null 값을 반환합니다.

예제

카테고리 데이터 출력하기

$thisCat = get_category(get_query_var('cat'),false);

print_r($thisCat);

produces;

stdClass Object
(
    [term_id] => 85
    [name] => Category Name
    [slug] => category-name
    [term_group] => 0
    [term_taxonomy_id] => 85
    [taxonomy] => category
    [description] => 
    [parent] => 70
    [count] => 0
    [cat_ID] => 85
    [category_count] => 0
    [category_description] => 
    [cat_name] => Category Name
    [category_nicename] => category-name
    [category_parent] => 70
)

참고

  • 분류(택소노미, Taxonomy) 로부터 카테고리를 얻으려면 get_term() 함수를 사용하세요.
  • 커스텀 포스트 타입이 표준 카테고리를 사용했을 경우, count 속성에 커스텀 포스트 타입도 포함한 값이 됩니다.

변경 사항

소스 파일

get_category() 함수는 wp-includes/category.php파일에 위치합니다.

관련 문서

See also index of Function Reference and index of Template Tags.