简体   繁体   中英

ACF Field Not Displaying in the Front End

I created a custom ACF Field called 'url' under the user registration data section which will carry the facebook homepage of the user . However when I try to use it in index.php template it is not working. It is showing no href link. I don't see anything wrong with the code.

     $author_id = get_the_author_meta('ID');
     $test=get_field('url', 'user_'.$author_id);
      ?>
    <div class="image"><a href="<?php echo $test; ?>" target="_blank"><?php echo $gravatar?></a>
    </div>

You need to specify the id of user:

For example:

get_field('url', 'user_1');

This code returns the url field of user with id = 1

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM