Support

Account

Home Forums General Issues Populate select field with post title Reply To: Populate select field with post title

  • I think I solved my own issue, the below seems to work, if anyone sees a flaw here please let me know, otherwise I hope this helps anyone with the similar issue.

    function acf_load_author( $field ) {
        
    	$field['choices'] = array();
    	
    	$the_query = new WP_Query( 'post_type=profiles' );
    		while ($the_query -> have_posts()) : $the_query -> the_post();
    		
    		$value = get_the_title();
    		$label = get_the_title();
    		
    		$field['choices'][ $value ] = $label;
    		
    		endwhile;
    
    	return $field;
    }
    
    add_filter('acf/load_field/name=author_select', 'acf_load_author');