I am a beginner of wordpress and ACF, and I have a question that I think it’s complicated and needs to customize the codes.
There are two pages, one is AUTHOR page with name, phone number, email, intro, avatar, etc., so I add those fields in the “author” group of fields and it shows everything perfectly in the author page. (There will be many authors.)
Another page is SERVICE page. There is a section in this page that I need to get some authors’ info in order to show these people could provide you the specific service.
In my mind I hope there’s checkbox in the “service” group of fields which users check the names and it will show those authors’ info without having to type them again and again in different service pages.
There’s lots of challenges: how to get the fields in another group of fields? and how to make it possible to show a stream of html codes when I just check the checkboxs in the ACF field?
Here is the codes I have now, but sorry it’s not complete. For now I still cannot get the fields in “author” group (which ID is 114) coz I don’t know how to structure them together:
<div class="service_member">
<a href="<?php echo esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ); ?>">
<?php $user_id = get_the_author_meta('ID'); $image = get_field('lawyer_image_sm', 'user_'.$user_id);
if( !empty($image) ): ?>
<img class="img-circle img-responsive img-center" src="<?php echo $image['url']; ?>" alt="<?php echo $image['alt']; ?>" style="float:left;">
<?php endif; ?>
<span class="service_name"><?php the_author(); ?></span>
</a>
<div class="service_info" style="clear:both;">
<br><span>Tel</span> <?php $user_id = get_the_author_meta('ID'); the_field('lawyer_tel', 'user_'.$user_id); ?>
<br><span>Mail</span> <?php $user_id = get_the_author_meta('ID'); the_field('lawyer_email', 'user_'.$user_id); ?>
</div>
</div>
The attached image is the capture of the checkbox field in the “service” group of fields, should I put any other codes here?
Thank you in advance for a great great great help!!!!
Instead of using a checkbox field try using a user field if. This creates a user relationship to users that allow you do select the users. Then on the service page you can get the values in the user relationship field, and this will let you get the values from the user.
You must be logged in to reply to this topic.
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 demoed ACF 6.1 Beta during the most recent session of ACF Chat Fridays, highlighting the new ability to regenerate and clear labels, setting the Admin Menu Parent as a slug, and more. Catch the video replay in our latest summary. https://t.co/rHEpPVas64 pic.twitter.com/hB1XKTexXi
— Advanced Custom Fields (@wp_acf) March 23, 2023
© 2023 Advanced Custom Fields.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.