How to add chained dropdown filter to a wordpress website
How to add chained dropdown filter to a wordpress website
How to add chained dropdown filter to a wordpress website
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
For the query_post function, it is recommended not to use according to official docs. query_posts() This function will completely override the main query and isn’t intended for use by plugins or themes……..This must not be used within the WordPress Loop. You may read this post to grasp more ideas. To query with multiple taxonomies, may … Read more
I found the answer, which for future reference was: /industries/food/?applications=processing
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
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
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; }
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
How do I stop the same post showing multiple times in a archive?
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