Home › Forums › Front-end Issues › Filter shortcode taxonomy list › Reply To: Filter shortcode taxonomy list
*Update
I managed to show only the checkbox with a value matching the ID of the current post with the following code:
function my_acf_load_field( $field )
{
global $post;
$post_id = get_the_ID();
$field['choices'] = array();
wp_reset_query();
$query = new WP_Query(array(
'post_type' => 'projectsoverview',
'orderby' => 'menu_order',
'order' => 'ASC',
'posts_per_page' => -1,
'tag' => $post_id
));
foreach($query->posts as $product_id=>$macthed_product){
$choices[$macthed_product->ID] = $macthed_product->post_title;
}
$field['choices'] = array();
if( is_array($choices) )
{
foreach( $choices as $key=>$choice )
{
$field['choices'][$key] = $choice;
}
}
wp_reset_query();
return $field;
}
Now I am trying to modify the query to only return the checkboxes that are checked. Is there a parameter that I can use for that purpose? Or is there another way?
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.