Is it possible to get_terms by taxonomy AND post_type?

Here is another way to do something similar, with one SQL query: static public function get_terms_by_post_type( $taxonomies, $post_types ) { global $wpdb; $query = $wpdb->prepare( “SELECT t.*, COUNT(*) from $wpdb->terms AS t INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id INNER JOIN $wpdb->term_relationships AS r ON r.term_taxonomy_id = tt.term_taxonomy_id INNER JOIN $wpdb->posts AS p … Read more

How to add capability to author role to assign custom taxonomy terms to a custom post type?

Yes. It is some kind of mapping. So now, when I register the custom taxonomy I pass it: $caps = array( ‘manage_terms’ => ‘activate_plugins’, ‘edit_terms’ => ‘activate_plugins’, ‘delete_terms’ => ‘activate_plugins’, ‘assign_terms’ => ‘edit_posts’ ); With this result authors can now assign terms. I am just using ‘activate_plugins’ because, by default, authors do not have this … Read more

ACF – How to get custom taxonomy term image field

I found a solution for this: <?php $current_term_id = get_queried_object_id(); $taxonomyName = “car-brand”; $parent_tax_ID = $current_term_id; $parent_tax = get_term($parent_tax_ID); $terms = get_terms( $taxonomyName, array( ‘parent’ => $parent_tax_ID, ‘orderby’ => ‘slug’, ‘hide_empty’ => false ) ); foreach ( $terms as $term ) { $image2 = get_field(‘am-brand-img’, $term); echo ‘ <div class=”am-ts-item”> <a href=”‘ . get_term_link( $term … Read more

Custom fields disappearing when a custom post type is assigned

I ended up solving this on my own and thought I would come back to show my solution. On my taxonomy page I needed to get the current taxonomy term like so: <?php $term = get_queried_object(); if (get_field(‘subtitle’, $term)) { ?> <p><?php the_field( ‘subtitle’, $term )?></p> <?php } ?> Here is the documentation page: https://www.advancedcustomfields.com/resources/adding-fields-taxonomy-term/