Last active
December 18, 2015 12:39
-
-
Save raphaelchaib/5784354 to your computer and use it in GitHub Desktop.
Wordpress: Get Category ID by name, slug or id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| // Get Category ID by name, slug or id | |
| function get_category_id($cat_slug, $field = 'slug', $taxonomy = 'category'){ | |
| $term = get_term_by($field, $cat_slug, $taxonomy); | |
| return $term->term_id; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment