Glossary with Custom Post Type

$index = 0; $terms = get_terms(‘marke’); $range = array_merge(range(0, 9), range(‘A’, ‘Z’)); echo ‘<ul>’; foreach ($terms as $term) { if(ord($range[$index]) <= ord(strtoupper(substr($term->name, 0, 1)))) { while($range[$index] != strtoupper(substr($term->name, 0, 1))) { echo ‘<li>’. $range[$index] . ‘</li>’; $index++; } $index = strtoupper(substr($term->name, 0, 1)); echo “<li><a href=””.get_term_link($term).”” />{$range[$index]}</a></li>”; $index++; } }

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

How to get_queried_object on multiple objects?

You almost had it with $_GET[‘zap_audience’], but not quite, since it isn’t passed in as a GET variable. It is however a query variable, so try these: $post_type = get_query_var( ‘post_type’ ); $audience = get_query_var( ‘zap_audience’ ); $city = get_query_var( ‘zap_cities’ ); Also +1 for prefixing your taxonomy types with zap_

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

Is it possible to have an index page for taxonomy term for each custom post type it is assigned to?

A simple method would be to create a archive template file for the location taxonomy, and then include the proper inner-template for each post type. First, create a PHP file in your theme’s root folder, named taxonomy-location.php. Then, you can use get_post_type() insider this template the include the proper template: get_template_part( ‘templates’, get_post_type() . ‘-content’ … Read more

Get terms of posts with category with sql

Here’s the solution: global $wpdb; $wpdb->get_results( $wpdb->prepare( “SELECT tags.*, COUNT(tags_rel.object_id) as posts_count FROM {$wpdb->prefix}terms tags INNER JOIN {$wpdb->prefix}term_taxonomy tags_tax ON (tags_tax.term_id = tags.term_id) INNER JOIN {$wpdb->prefix}term_relationships tags_rel ON (tags_tax.term_taxonomy_id = tags_rel.term_taxonomy_id) INNER JOIN {$wpdb->prefix}posts posts ON (tags_rel.object_id = posts.ID) INNER JOIN {$wpdb->prefix}term_relationships cats_rel ON (posts.ID = cats_rel.object_id) INNER JOIN {$wpdb->prefix}term_taxonomy cats_tax ON (cats_rel.term_taxonomy_id = cats_tax.term_taxonomy_id) … Read more

Sorting for each custom taxonomy

Is there a way to handle this unique ordering for each term in the taxonomy? You can use custom fields to store the order of the players (e.g.: team_order, league_order, position_order). And dynamically modify the order in your index, archive or taxonomy template file (whatever you use): if( is_tax(array(‘team’,’league’,’position’)) ) { if( is_tax(‘team’) { $wp_query->set(‘meta_key’, … Read more