Tag Info

New answers tagged

1

Try using has_term(). Something like this: <?php if( has_term('term1', 'taxonomy_name', $post) ) { ?> <img src="http://www.site.com/wp-content/themes/site/img/stars-01.png" width="100" height="21" alt="default"> <?php }elseif ( has_term( 'term2', 'taxonomy_name', $post) ) { ?> <img ...


-1

At a super-duper simple scale, what about just: echo strip_tags( get_the_term_list($post->ID, 'type') )


0

Assuming that: slug of your taxonomy is movie slug of your term is b you are using pretty permalinks your website is accessible at: www.example.com You can see a list of all posts which have been assigned this specific term under this taxonomy by going to: www.example.com/movie/b/ This page will display posts from all custom post types to which this ...


2

Keep in mind that the return value of get_the_terms() can be of the type of array|WP_Error Your snippet should check if you get the correct type returned $terms = get_the_terms( 0, 'product_tag' ); if ( ! is_wp_error( $terms ) AND is_array( $terms ) AND ! empty( $terms ) ) { foreach( $terms as $term ) printf( ...


0

Thanks to Mark, I solve this successfully. Update: Thanks to Kaiser part of the code has been updated. Here is the final code. <?php $custom_terms = get_the_terms(0,'product_tag'); if ( ! is_wp_error( $custom_terms ) AND is_array( $custom_terms ) AND ! empty( $custom_terms ) ) { foreach ...


0

My bad - the mark up for the edit page is different than add. Used this instead add_action('provider_edit_form_fields', array($this, 'category_metabox_edit'), 10, 1); // add image field in edit form function category_metabox_edit($tag) { $term_val = get_term_meta($tag->term_id, 'show_on_provider', true); $term_val == 1 ? $checked = 'checked' : ...


1

It is not advised to run custom queries in place of the main query. What you are trying to do is already done by the main query. In short, you are trying to reinvent the wheel :-). Your no 1 solution would be to return to the default loop, and apply changes to the main query through pre_get_posts. Check this post for more info Just on your code, you are ...


0

You need to combine two tax queries with and AND relation: $args = array( 'posts_per_page' => 10, // Number of posts per page 'post_type' => 'classifieds', // Custom Post Type like Movies 'tax_query' => array( 'relation' => 'AND' array( 'taxonomy' => 'classifieds_tags', //Custom Taxonomy Name like ...


0

Something like this should help: <?php $post_type = 'animals'; $tax = 'vertebrate'; $tax_terms = get_terms($tax); if ( $tax_terms ) { foreach ($tax_terms as $tax_term) { $args = array( 'post_type' => $post_type, "$tax" => $tax_term->slug, 'post_status' => ...



Top 50 recent answers are included