@pickles can you post your code?
I actually don’t remember what I did to fix my issue but I will look back at my code tomorrow and compare it with what you have.
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');
Sorry for bringing this post back again, I am trying this solution, but
if( in_array( $title == $selection ) ) {
Seems to lose my repeater. If I remove it all the repeater rows will show.
The code I am using is below, any feedback on where I’ve gone wrong would be a huge help to me.
<?php
$selection = get_field('author_select');
if( !empty( $selection ) ) {
if( have_rows( 'user_profile', 'option' ) ) {
while( have_rows( 'user_profile', 'option' ) ) {
the_row();
$title = get_sub_field('full_name');
if( in_array( $title == $selection ) ) {
$title = get_sub_field('full_name');
$org = get_sub_field('organization');
$img = get_sub_field('profile_image');
?>
<figure id="author">
<div class="d-grid">
<div class="left-contents">
<h4>ABOUT THE AUTHOR:</h4>
<div id="author-avatar"><img src="<?php echo $img; ?>" alt="<?php echo $title; ?>" /></div>
</div>
<div class="mid-contents">
<h5><?php echo $title; ?> | <?php echo $org; ?></h5>
</div>
</div>
</figure>
<?php
}
}
}
}
?>
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.