How to get custom category’s link?

As the other’s mentioned, wp_list_categories will work if you you want to do a list of things (just like wp_list_pages does for pages). If you specifically want the link (URL), you can use get_term_link. If you just have the term ID, it would look something like this. <?php $term_id = some_function_that_returns_term_id(); $term_link = get_term_link($term_id, ‘your_custom_taxonomy’); … Read more

Foreach loop duplicating a taxonomy thumbnail image

1). Inside your foreach (term child) loop you first have: echo wp_get_attachment_image( $termThumb->image_id, ‘thumb’ ) ; but $termThumb isn’t set yet. So on the first iteration it doesn’t do anything. 2) Then you have another foreach loop: if ( ! empty( $termThumbs ) ) { foreach( $termThumbs as $termThumb ) { print wp_get_attachment_image( $termThumb->image_id, ‘thumb’ … Read more

Default taxonomy template in plugin, override in theme

This is what I ended up using (for all those interested): function override_tax_template($template){ // is a specific custom taxonomy being shown? $taxonomy_array = array(‘tax1′,’tax2’); foreach ($taxonomy_array as $taxonomy_single) { if ( is_tax($taxonomy_single) ) { if(file_exists(trailingslashit(get_stylesheet_directory()) . ‘tax-template-directory/taxonomy-‘.$taxonomy_single.’.php’)) { $template = trailingslashit(get_stylesheet_directory()) . ‘tax-template-directory/taxonomy-‘.$taxonomy_single.’.php’; } else { $template = BASE_PLUGIN_DIR . ‘includes/tax-template-directory/taxonomy-‘.$taxonomy_single.’.php’; } break; } } … Read more

Exclude posts with custom taxonomy

Make sure to reread the tax_query documentation. If you change it to this, I think it should work: ‘tax_query’ => array( array( ‘taxonomy’ => ‘news’, ‘field’ => ‘id’, ‘terms’ => 51, operator => ‘NOT IN’ ) ) Depending on your setup, you may also want to specify the include_children argument.

How to write sql query to get the posts from a custom taxonomy term name

@Sisir linked you to the appropriate place, if you had read the question/answer and the linked Codex documentation you’d have seen that you could do something like the following: $args = array( ‘post_type’ => ‘dealers’ ‘tax_query’ => array( array( ‘taxonomy’ => ‘state’, ‘field’ => ‘slug’, ‘terms’ => array(‘bob’,’angela’,’john’,’smith’,’jan’,’doe’,’etc…’) ) ) ); $query = new WP_Query( … Read more

Query posts using custom taxonomy and selected terms

You’re using a deprecated method of querying by taxonomy. Read the Codex and use tax_query: $args=array( ‘post_type’ => ‘book’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘facts’, ‘field’ => ‘slug’, ‘terms’ => ‘information’ ) ) ); FYI, caller_get_posts is also deprecated.