Single.php for Custom Post Type > Taxonomy > Term

You can load a different template for single posts via the single_template filter. Just use the has_term() function to check if the post has a specific term in your custom taxonomy. function wpa_107626_single_template( $single_template ) { // check if the post fits some condition if ( has_term( ‘term1’, ‘film_cat’ ) ) { $single_template = get_stylesheet_directory() … Read more

Custom Post type Query by Taxonomy

I think showposts was replaced by posts_per_page in wordpress 2.1. See pagination parameters. Also note that print_r($query) won’t return any results because $query variables is WP_Query object; you need to exceute the query. $args = array( ‘post_type’ => ‘contractors’, ‘posts_per_page’ => -1, ‘tax_query’ => array( array( ‘taxonomy’ => $taxonomy, ‘terms’ => $taxarray, ‘field’ => ‘id’ … Read more

Query custom taxonomy for category including children

tax_query is used to get the posts associated with certain taxonomy. {tax} (string) – use taxonomy slug. Deprecated as of Version 3.1 in favor of ‘tax_query’. tax_query (array) – use taxonomy parameters (available with Version 3.1). taxonomy (string) – Taxonomy. field (string) – Select taxonomy term by (‘id’ or ‘slug’) terms (int/string/array) – Taxonomy term(s). … Read more

How to List Custom Post Type Titles Based on Theirs Taxonomy Terms Inside a Nested Loop

Retrieval of multiple posts in WordPress is almost always handled by WP_Query class (or get_posts() function that wraps it). There is quite a lot of documentation and information to it, but to narrowing it down to your specific case you will need to: set up posts loop for each term pass as arguments to each … Read more

Custom post type (Jigoshop): unexpected value for $category_id (via $term->term_taxonomy_id) on live server

For a Category landing page that only shows each ‘product_cat’ image that links to a separate page for each category, I have the following template enclosed. It doesn’t use $term->term_taxonomy_id but rather $term->term_id. Not sure if it will help, but look it over for differences from what you have. <?php /** * Product taxonomy template … Read more

WP_Query tax_query – Show results if child has parent X

If I’m understanding you correctly get_term_children does what you want. $term_id = 2; $tax_name=”locations”; $term_child = get_term_children( $term_id, $tax_name ); Another possibility would be using get_categories, it has an child_of, taxonomy and depth parameter – the documentation on wp_list_categories, which offers pretty much the same functionality, is better.

How to have multiple instances of the same taxonomy in a search form

jpd527, Please remember that ‘tag’ is singular and not plural. Here your form has multiple HTML element with same id so this is wrong. Now if you require to search data with two different inputs, then you can merge it via JS. HTML code like: <form method=”get” id=”search form” action=”https://wordpress.stackexchange.com/”> <div> <input type=”text” value=”” name=”tag_one” … Read more