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

The same slug in multiple taxonomies

When you say keyword, do you mean term? I just did a quick test to confirm: I can have the same term, which has the same slug, in both the Category and Post Tag taxonomies, so I assume that custom taxonomies likewise can have terms with the same slug. So, might there be some taxonomy/term … Read more

Retrieving custom taxonomy in order, but excluding specific tax IDs

Alas no answers or comments! 😛 Not to worry, a colleague helped me out here and here is the above code working with an $exclude function terms_by_order($taxonomy, $exclude) { global $post; $terms = get_the_terms($post->ID, $taxonomy); // check input if ( empty($terms) || is_wp_error($terms) || !is_array($terms) ) return; // exclude foreach ($terms as $key=>$term) { if … Read more

register_rest_field for custom taxonomy fields that are assosiated with custom post type

Both callbacks in the register_rest_field_for_custom_taxonomy_location() function are misspelled. change ‘get_callback’ => ‘location_get_term_meta’, ‘update_callback’ => ‘location_update_term_meta’, to ‘get_callback’ => ‘location_get_term_meta_field’, ‘update_callback’ => ‘location_update_term_meta_field’, Register Code function register_rest_field_for_custom_taxonomy_location() { register_rest_field( ‘location’, ‘location_code’, array( ‘get_callback’ => ‘location_get_term_meta_field’, ‘update_callback’ => ‘location_update_term_meta_field’, ‘schema’ => null, ) );

Post tags saving as both tag name & tag ID on post update when tags are displayed as checkboxes

Faced this problem too. You can solve it adding to functions.php filtering code: add_action( ‘admin_init’, function() { if( isset( $_POST[‘tax_input’] ) && is_array( $_POST[‘tax_input’] ) ) { $new_tax_input = array(); foreach( $_POST[‘tax_input’] as $tax => $terms) { if( is_array( $terms ) ) { $taxonomy = get_taxonomy( $tax ); if( !$taxonomy->hierarchical ) { $terms = array_map( … Read more