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

Nice URLs for a Custom Post Type List with a Shared Custom Taxonomy?

For the first preference, you’d need to filter in additional rewrite rules like so; function __extra_country_rewrite_rules( $rules ) { global $wp_rewrite; if ( !isset( $wp_rewrite ) ) $wp_rewrite = new WP_Rewrite; $m1 = $wp_rewrite->preg_index(1); // preg match backreferences $m2 = $wp_rewrite->preg_index(2); $m3 = $wp_rewrite->preg_index(3); $rules[‘country/([^/]+)/([^/]+)s/feed/(feed|rdf|rss|rss2|atom)/?$’] = “index.php?country=$m1&post_type=$m2&feed=$m3”; $rules[‘country/([^/]+)/([^/]+)s/(feed|rdf|rss|rss2|atom)/?$’] = “index.php?country=$m1&post_type=$m2&feed=$m3”; $rules[‘country/([^/]+)/([^/]+)s/page/?([0-9]{1,})/?$’] = “index.php?country=$m1&post_type=$m2&paged=$m3”; $rules[‘country/([^/]+)/([^/]+)s/?$’] = … Read more