New answers tagged

-1

You are overwriting $product_cat_slugs on every iteration of your loop - so when it's finished, that variable will be set to the last value. Why not do all of your outputs inside that loop? Or if for some reason you don't want to do that, make $product_cat_slugs an array instead of a variable: $product_cat_slugs = []; foreach ($terms as $term) { $...


1

$keys = array_column($terms, 'slug'); array_multisort($keys, SORT_ASC, $terms); That did the trick and let me sort terms in that muli array.


-1

while ( $loop->have_posts() ) : $loop->the_post(); //Edit Width post type $categories = get_the_terms(get_the_ID(), 'services'); $separator = ', '; if ( ! empty( $categories ) ) { foreach( $categories as $category ) { echo '<a class="cat_item" href="' . esc_url( get_category_link( $category->term_id ) ) . '" alt="' . ...


0

I don't realy understand how to use get_terms(), and maybe, get_term_children() for deal with this. I believe you're missing 3 important pieces of information: terms that have no parent have a parent ID of 0 you can ignore get_term_children, just use the parent parameter of get_terms for this to work more than one or two levels deep you will need to put ...


0

hide_empty hides terms that have no posts attached to them. You've got a page with no ht_kb_tags attached to it, if I'm understanding the question correctly. Since get_the_terms() returns false if there are no terms, you should be able to prevent the foreach() with an if() statement: $mget_site_url = get_site_url(); //This gets me all the correct terms... $...


Top 50 recent answers are included