Today i spent some time trying to figure how to get existing (and also used) tags from wordpress and using in admin panel as a combo box, for my brand new theme Wordnewz.
The return of get_tags() function was some kind of array but, because of my skills (not) in PHP i spend WAY too much time to go figure what to do. The initial result of get_tags() function is:
Array
(
[0] => stdClass Object
(
[term_id] => 28
[name] => Featured
[slug] => featured
[term_group] => 0
[term_taxonomy_id] => 29
[taxonomy] => post_tag
[description] =>
[parent] => 0
[count] => 6
)
)
And i only needed [name] and [slug]. Ofcourse, like a smart guy that i am, i pointed my browser on wordpress codex where i found… NOTHING. Nothing about this function… Great. Let’s try various stuff and google it for any ideas. And i found a PHP function get_object_vars for easy conversion. After this, all was GREAT. I use it like this:
$allTags = get_tags();
foreach($allTags as $thisTags) {
$thisTag = get_object_vars($thisTags);
echo '
\n';
}
And it WORKS like a charm. I posted this thing because i didn’t found too much references for stdClass Object or get_tags() WordPress function.
No related posts.
the reason for not finding anything about stdClass is that PHP doesn’t give an error when a class is used but not loaded, PHP uses a “STanDard Class” to deal with this kind of situations
what does this mean from a front-end development point of view? well, if you need to access/use a method (ex. function test() {}) of a class which you thought was loaded, you will receive an error because the standard class does not have the test() method
hope this helps you a bit
Thanks for post, It really helped me.
sweet! this post could have been written by me till “…i pointed my browser on wordpress codex where i found… NOTHING.”. then i asked google and the answer was your page. thanks for sharing!!!
Thanks! You helped me so so much!
I had the same problem! The only difference is that I need this for custom menu.
WOW! Thanks! Really helpful!