Support

Account

Home Forums Backend Issues (wp-admin) Dynamically Load Select Choices with Functions Reply To: Dynamically Load Select Choices with Functions

  • I guess I need to use a filter. I modified the function to the following (so $field holds that array I was talking about in the initial post) and added the filter but still no luck… Any ideas? I really appreciate your help!

    function get_waiting_lists( $field ) {
    	
    	$field = array();
    
    		// Query Waiting Lists Products
    		$args = array(
    			'post_type' => 'memberpressproduct',
    			'orderby' => 'name',
    			'order' => 'ASC',
    			'posts_per_page' => -1,
    			'tax_query' => array(
    				array(
    					'taxonomy'  => 'topics',
    					'field'     => 'id',
    					'terms'     => '22',
    					'operator'  => 'IN'
    				),
    			)
    		);
    		$lists_array = get_posts( $args );
    		
    			foreach ( $lists_array as $list ) {
    				
    				$field[$list->ID] = $list->post_title;
    			
    			}
    	
    	wp_reset_postdata();
    
    	return $field;
    }
    
    add_filter('acf/load_field/name=select_waiting_list', 'get_waiting_lists');