Home › Forums › Front-end Issues › Only list custom post types that match sub field taxonomy › Reply To: Only list custom post types that match sub field taxonomy
I think I have solved it.
From what I understand for a taxonomy the value mst be the ID rather than the name or slug or whatever, so since I need to use the name I need to convert that to the ID. I found that I could do this using get_term_by();
This is the portion of code I needed to change:
// Get term by name 'windows' in custom taxonomy 'product-types'. $termId = get_term_by( 'name', 'windows', 'product-types' ); // compose our query arguements $args = array( 'post_type' => 'colourswatch', 'meta_query' => array( array( 'key' => 'colour_swatch_$_availability', // repeater_$_subfield 'value' => $termId->term_id, // translate the term name into its ID 'compare' => 'LIKE' ) ) );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
Accordions are a great way to group related information while allowing users to interactively show and hide content. In this video, Damon Cook goes in-depth on how to create an accessible accordion block using ACF PRO’s Repeater field.https://t.co/RXT0g25akN— Advanced Custom Fields (@wp_acf) March 2, 2023
© 2023 Advanced Custom Fields.