Quantcast
Channel: User janh - WordPress Development Stack Exchange
Viewing all articles
Browse latest Browse all 40

Answer by janh for Get Term names from WP Term Object

$
0
0

Sound like a strange thing to do, but I've seen stranger requirements, so I trust you have a good reason for that.

$names = array();$slugs = array();$terms = get_terms(array('taxonomy' => 'product_cat','hide_empty' => false,));foreach($terms as $term) {    array_push($names, $term->name);    array_push($slugs, $term->slug);}

Will create those two arrays. Note that I've renamed the variable you called $taxonomies as it's confusing to name it after one thing when it contains another (in this case it will contain terms, not taxonomies).


Viewing all articles
Browse latest Browse all 40

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>