Show a Category X’s custom post type on Category X archive page?

I’d suggest adding something like this to the top of the theme file or wherever you want this content to appear in the archive, category or whatever.. // Check if it’s a category or taxonomy archive if( is_category() || is_tax() ) { // Grab the queried data, slug, tax, etc.. $queried = $wp_query->get_queried_object(); // Check … Read more

has_term if/echo else/echo function

Problem is that you’d need to pass a $post->ID in order to not return false. Better use is_object_in_taxonomy($object_type, $taxonomy) and fill both the term and the tax in the function. It returns (boolean), so simply add your class based on the result: echo $class = is_object_in_taxonomy( ‘news’, ‘your_taxonomy’ ) ? ‘current-whatever’ : ”; // or: … Read more

List custom taxonomy specific to one custom post type

Here’s an example that will list all the mobile_review posts that have the term htc_desire_hd in the taxonomy mobile_phone : $tax_query = array( ‘relation’ => ‘AND’ ); $tax_query[] = array( ‘taxonomy’ => ‘mobile_phone’, ‘terms’ => array(‘htc_desire_hd’), ‘field’ => ‘slug’ ); $args = array( ‘post_type’ => ‘mobile_review’, ‘tax_query’ => $tax_query ); $custom_loop = new WP_Query( $args … Read more

A question on creating filters for custom posts using taxonomy

you can check on your taxonomy-services.php what is the current queried term filter based on that, something like this: //get the current term $term_slug = get_query_var( ‘term’ ); //get the current taxonomy $taxonomyName = get_query_var( ‘taxonomy’ ); //get the term object if you want $current_term = get_term_by( ‘slug’, $term_slug, $taxonomyName ); //then you can query … Read more