taxonomy terms are not populating select tag options

I believe this has more to do with the ternary operator being used inside of string concatenation. I would eliminate this issue by relying on a classic if statement, but WordPress provides a helpful function selected, giving us: $terms = get_terms( ‘department’ ); if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) … Read more

Get terms parent ID for conditional IF statement

While this is not specifically WordPress but some general PHP, here’s a solution which you could use: $terms = get_the_terms( $post->ID , ‘prodcats’ ); foreach( $terms as $term ) { $classes=”categoryblock”; switch( $term->parent ) { case 3: $classes .= ‘ blue’ // Notice the space between the opening string – important for CSS break; } … Read more

Wrap custom terms loop

Here is solution, split in arrays: <?php foreach (array_chunk(get_terms( ‘razotajs’, ‘orderby=count&order=DESC&hide_empty=0&parent=0’ ), 6, true) as $array) { echo ‘<div class=”logo_sets”>’; foreach($array as $cat) { ?> <a href=”https://wordpress.stackexchange.com/questions/224950/<?php echo get_term_link($cat->slug,”razotajs’); ?>” title=”<?php echo $cat->name; ?>”><img src=”<?php echo z_taxonomy_image_url($cat->term_id); ?>” alt=”<?php echo $cat->name; ?>” /></a> <?php } echo ‘</div>’; } ?>