How to search through all child taxonomies using WP_Query?

Finally figured out the solution. Answering it if anyone finds it useful. Where $_GET[‘s_qr’] has a search query from a user from another page. $i = 0; $parent_name=””; $taxonomyName = “product-cat”; $search_r = array(); $parent_terms = get_terms( $taxonomyName, array( ‘parent’ => 0, ‘orderby’ => ‘slug’, ‘hide_empty’ => false ) ); foreach ( $parent_terms as $pterm … Read more

Order get_terms by count using a custom taxonomy hierarchy

Don’t know if it’s the best solution but I ended up using a custom query to show all categories ordered by count. $cats = $wpdb->get_results(” select tt.term_id, count, name, slug from “.$wpdb->prefix.”term_taxonomy as tt inner join “.$wpdb->prefix.”terms as terms on tt.term_id = terms.term_id where taxonomy = ‘product_cat’ order by count desc limit 10 “); echo … Read more

How do I find out which (page) template file my custom child post is looking for?

If think you were using the wrong filter, please try using ‘single_template’. I assume you have created a plugin to create your custom post type. In the plugin folder you have a “templates” folder where you put the single page template called “palaver_single.php”. function palaver_single_mapping($single) { global $post; if ( $post->post_type == ‘palaver’ ) { … Read more

How to exclude woocommerece product category in search results?

function exclude_product_category( $query ) { if ($query->is_search()) { $tax_query = (array) $query->get(‘tax_query’); $tax_query[] = array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘slug’, ‘terms’ => array(‘excluded-category’), ‘operator’ => ‘NOT IN’ ); $query->set(‘tax_query’, $tax_query); } return $query; }

Excluded Custom Taxonomy Term Posts Displaying in loop

Try below methods: Try by adding term ID in array like this ‘exclude’=> ’60’ in array If this is not working you can try with below WP_Query loop: $args = array( ‘post_type’ => ‘careers’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘careers_categories’, ‘field’ => ‘term_id’, ‘terms’ => array( 60), ‘operator’ => ‘NOT IN’, … Read more

Filter in Custom post type to find the parent post

Let’s if it helps you. Instead of adding a custom query var if we can use directly from url that might solve the issu. First make post_parent loadable from url. function make_post_parent_public_qv() { global $pagenow; if ( is_admin() && $pagenow == ‘edit.php’ ) $GLOBALS[‘wp’]->add_query_var( ‘post_parent’ ); } add_action( ‘init’, ‘make_post_parent_public_qv’ ); Now focus on the … Read more