A Comma Between Each Items Except the Last One with get_the_term_list [duplicate]
get_the_term_list uses get_the_terms to fetch the term objects. You can use that function instead and build the list however you’d like.
get_the_term_list uses get_the_terms to fetch the term objects. You can use that function instead and build the list however you’d like.
I don’t know why that code didn’t work for you. I copy that code and it work exactly as I expected. You should double check your case, did you unset $args variable before, or you can use another name ($agrs2 for example). Another problem in you question is: if pad_counts doesn’t work, you will get … Read more
Resolved: Just needed to add trim to the term names retrieved from the custom DB table!! D’oh!
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
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>’; } ?>
Try relying on the new WP_Term_Query() class, here’s an example per your code: // WP_Term_Query arguments $args = array( ‘taxonomy’ => ‘carabana_Cat’, ‘hide_empty’ => false, ‘orderby’ => ‘description’, ‘child_of’ => 28) ); // The Term Query $term_query = new WP_Term_Query( $args );
If you want to achieve that, then you need to add creation_date for each taxonomy, hooked with ‘create_category’ (or create_YOURTAXONOMYNAME) function. lets say,for example, you add a new category : add_action( “create_category”, ‘my_func123’, 10, 2 ); function my_func123( $term_id, $tt_id){ update_option(‘my_taxnm_date_’.$term_id, time()); } then later, anytime, you will be able to get the creation date … Read more
Enter wp_get_object_terms – it accepts an array of object IDs and retrieves all of their (unique) attached terms: $terms = wp_get_object_terms( [ 1, 2, 3 ], ‘category’ ); foreach ( $terms as $term ) echo “$term->name<br />”;
wp_get_object_terms! For example, if we want to grab all terms in a product taxonomy for a post we might do: $product_terms = wp_get_object_terms( $post->ID, ‘product’ ); if ( ! empty( $product_terms ) ) { if ( ! is_wp_error( $product_terms ) ) { echo ‘<ul>’; foreach( $product_terms as $term ) { echo ‘<li><a href=”‘ . get_term_link( … Read more
$terms = get_the_term_list( $post->ID, ‘post_tag’, ‘Tags: ‘, ‘, ‘, ”); echo preg_replace(‘/^(.+),([^,]+)$/’, ‘$1 &$2’, $terms); Explanation for /^(.+),([^,]+)$/: / – delimiter ^ – string beginning .+ – 1 or more characters [^,]+ – 1 or more characters that are not a comma $ – string end $n is the nth match i.e. nth pair of … Read more