Created
April 7, 2011 14:55
-
-
Save danott/907922 to your computer and use it in GitHub Desktop.
As far as I can google, WordPress offers no convenient way for accessing some things I'd like to use.
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 | |
| // Utilize wordpress' get_queried_object to get the details necessary. | |
| function current_category_ID() | |
| { | |
| $category = get_queried_object(); | |
| return $category->term_id; | |
| } | |
| // Boolean: Does this category have child categories. | |
| function category_has_children($category_ID) | |
| { | |
| $test_word = 'THIS_IS_MY_TEST_FOR_NO_CHILDREN_LA_LA_LA_LA_LA'; | |
| $children = wp_list_categories( | |
| array( | |
| 'child_of' => $category_ID | |
| , 'echo' => false | |
| , 'hide_empty' => false | |
| , 'hierarchical' => true | |
| , 'show_option_none' => $test_word | |
| , 'style' => 'none' | |
| , 'title_li' => '' | |
| )); | |
| return !($children == $test_word); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment