Decrement term in for each
Decrement term in for each
Decrement term in for each
Resolved: Just needed to add trim to the term names retrieved from the custom DB table!! D’oh!
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
For the archive by the term, you should go with taxonomy template. For you it will be taxonomy-project.php When you work with custom post type , you should update the permalink structure when you make changes on templates, I mean register new post type or create new template file
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>’; } ?>
Instead of trying to do this through the orderby parameter, I went a different direction. Logically, the orderby parameter above only applies to the posts within each grouping, not the taxonomy term grouping itself so it won’t work for this. What I ended up doing was adding 01, 02, 03, etc. to the taxonomy term … Read more
You need to use the methods of your query instance, rather than the global functions (which are merely wrappers for the global $wp_query): if ( $query->have_posts() ) { $term = $query->queried_object; while ( $query->have_posts() ) : $query->the_post(); //Output my posts the_title(); the_content(); endwhile; }
I might be completely missing what you want here, but it sounds like you’re saying you want the parent category’s slug to echo out, rather than the parent category’s human readable name. Rather than this: echo $parent->name; You just need this instead: echo $parent->slug; You can see a list of the properties here that are … Read more
‘LIKE’ isn’t supported by the current version of WP_Tax_Query, so you’ll need to write a custom query. This answer from a couple of years ago still seems to be the best approach: https://wordpress.stackexchange.com/a/133805/26317.