Custom-Taxonomy as categories: Remove “most-used” tab?

Yes – you need to first ‘de-register’ the metabox WordPress automatically creates: add_action( ‘admin_menu’, ‘myprefix_remove_meta_box’); function myprefix_remove_meta_box(){ remove_meta_box(‘my-tax-metabox-id’, ‘post’, ‘normal’); } Where my-tax-metabox-id is the ID of your metabox. Then ‘re-register’ the metabox providing your own callback function which produces in the output: //Add new taxonomy meta box add_action( ‘add_meta_boxes’, ‘myprefix_add_meta_box’); function myprefix_add_meta_box() { add_meta_box( … Read more

Get main parent categories for a product

just to offer a alternative solution that might help somebody: code function wc_origin_trail_ancestor( $link = false, $trail = false ) { if (is_product_category()) { global $wp_query; $q_obj = $wp_query->get_queried_object(); $cat_id = $q_obj->term_id; $descendant = get_term_by(“id”, $cat_id, “product_cat”); $descendant_id = $descendant->term_id; $ancestors = get_ancestors($cat_id, ‘product_cat’); $ancestors = array_reverse($ancestors); $origin_ancestor = get_term_by(“id”, $ancestors[0], “product_cat”); $origin_ancestor_id = $origin_ancestor->term_id; … Read more

custom post type taxonomies UI radiobuttons not checkboxes

When you register a taxonomy WordPress automatically handles producing the appropriate metabox. First you need to ‘de-register’ this default metabox: add_action( ‘admin_menu’, ‘myprefix_remove_meta_box’); function myprefix_remove_meta_box(){ remove_meta_box(‘my-tax-metabox-id’, ‘post’, ‘normal’); } Where my-tax-metabox-id is the ID of your metabox. Then ‘re-register’ the metabox providing your own callback function which produces in the output: //Add new taxonomy meta … Read more

How to check if last uri segment is a custom post type or taxonomy term?

To see how we can make this work, have a read through the Query Overview Codex page, particularly the What Plugins can Modify section: Modify the query specification, after variable values are saved (request filter or parse_request action; if you want to use conditional tag tests, use the parse_query or pre_get_posts action, as these run … Read more

wp_get_object_terms – How can I order the resulting array by hierarchy?

Just a rough sketch to get your idea: countries (hierarchical taxonomy) France (country – sub taxonomy) Champagne (state – sub sub taxonomy) Le Mans (city – term) Angers (city – term) Nantes (city – term) And you want to order: $query_results = query( ‘country’ => ‘france’, ‘orderby’ => ‘state city’, ‘order’ => ‘ASC’ ); Did … Read more

Sort posts by number of matched terms

Well the only way i can think of is to create an two dimentions array of the results you want to output, and the number of matching tags. so for example: $results = array(); $searched_tags = $_post[‘my_tax’]; $searched_tags = explode(“+”, $searched_tags); while (have_posts()){ $the_post(); $result[‘r’] = ‘<div class=”post”> <div class=”title”><h2><a href=”‘.get_permalink($post->ID).'” title=”‘.get_the_title($post->ID).'”>’.get_the_title($post->ID).'</a></h2></div> <div class=”excerpt”>’.get_the_excerpt().'</div> </div>’; … Read more