| | 949 | * Find a term in taxonomy by its hierarchical slug. |
| | 950 | * |
| | 951 | * If the term does not exist - null will be returned. |
| | 952 | * If the term exists - term object will be returned. |
| | 953 | * |
| | 954 | * @param string $slug term slug |
| | 955 | * @param string $taxonomy Taxonomy to search in |
| | 956 | * @return object Term Row from database. Will return null if $taxonomy does not exist or $term was not found. |
| | 957 | */ |
| | 958 | |
| | 959 | |
| | 960 | function get_term_by_slug($slug, $taxonomy, $parent = 0){ |
| | 961 | list($slug, $remaining) = split('/', $slug, 2); |
| | 962 | $terms = get_terms(array($taxonomy), array( |
| | 963 | 'slug' => $slug, 'hide_empty' => false, |
| | 964 | 'parent' => $parent |
| | 965 | )); |
| | 966 | if (!count($terms)){ |
| | 967 | return null; |
| | 968 | } |
| | 969 | if ($remaining){ |
| | 970 | return get_term_by_slug($remaining, $taxonomy, $terms[0]->term_id); |
| | 971 | } |
| | 972 | return $terms[0]; |
| | 973 | } |
| | 974 | |
| | 975 | /** |