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 so that I can run the plugin function
z_taxonomy_image_url($currentID); which outputs a URL based on the category identified by
I have a very hacky solution at the moment, but if anyone can figure out why the last 3 lines of the following bit of code doesn'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'); $currentID = $getID->term_id;
$getID only results in
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'); $currentID = $getID->term_id;
Is there something with
get_term_by that it rejects using
$newtax but accepts
'Volume 2 Issue 1' ? If yes, is there a workaround or do I need to look for some other way of doing this?
I am not very well versed in PHP and WP codes. I am not afraid of tinkering, but my knowledge is only basics :( Please bear with me.
Thank you for your time.