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');
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.