Support

Account

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?