I am wondering if there is any reason why the following code would not work?
My situation: I have a custom category set up called 'Issue'. What I want to do is get the most newly created category (which is 'Volume 2 Issue 1') and get its ID.
I have a very hacky solution at the moment, but if anyone can figure out why the last 3 lines don't work, it would be fantastic.
Alternative and cleaner solutions would also be appreciated.
$taxonomy=wp_list_categories('taxonomy=issue&echo=0&number=1&orderby=ID&order=DESC&show_count=0&style=none&title_li='); $tax = strip_tags($taxonomy); $newtax = "'".trim($tax)."'"; $getID = get_term_by('name', $newtax, 'issue'); $curID = $getID->term_id;
$getID only results in this:
The interesting thing is that this code works (but I cannot use it because it would require manually changing the code each time I create a new category).
$getID = get_term_by('name', 'Volume 2 Issue 1', 'issue'); $curID = $getID->term_id;
(cross-post from http://wordpress.org/support/topic/get_term_by-and-variables?replies=1 because I didn't know this subforum existed. Sorry mods!)