Skip to content

Instantly share code, notes, and snippets.

@danott
Created April 7, 2011 14:55
Show Gist options
  • Select an option

  • Save danott/907922 to your computer and use it in GitHub Desktop.

Select an option

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.
<?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