Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




get_cat_id [ WordPress Function ]

get_cat_id ( $cat_name = 'General' )
Parameters:
  • (string) $cat_name Optional. Default is 'General' and can be any category name.
Returns:
  • (int) 0, if failure and ID of category on success.
Defined at:



Retrieve the ID of a category from its name.

Source


<?php
function get_cat_ID$cat_name='General' ) {
    
$cat get_term_by'name'$cat_name'category' );
    if ( 
$cat )
        return 
$cat->term_id;
    return 
0;
}
?>

Examples [ wp-snippets.com ]

Google Arama Sonuçlarý

Dahasý ...

0 User Note(s)

Henüz yok. Ýlk sen ol!

Yeni Ekle ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics