dqlb38410 2015-11-16 11:41
浏览 36

使用ACF的Wordpress中的作者列表

I am creating a special page to show up all the authors and contributors for a website. I'm using ACF fields for the users and these fields are not showing up.

According to ACF support, I should use this:

    <?php

$author_id = get_the_author_meta('ID');
$author_badge = get_field('author_badge', 'user_'. $author_id );

?>
<img src="<?php echo $author_badge['url']; ?>" alt="<?php echo $author_badge['alt']; ?>" />

My code at the moment is:

<?php
      foreach($users as $user)
      {
         ?>
         <div class="s-12 l-4 margin-bottom">

               <div class="theBox">
               <figure class="effect-zoe">

            <p><?php echo get_the_author_meta( $userID ); ?></p>

                  <?php

$author_id = get_the_author_meta('ID');
$author_badge = get_field('author_badge', 'user_'. $author_id );

?>
<img src="<?php echo $author_badge['url']; ?>" alt="<?php echo $author_badge['alt']; ?>" />


                  <figcaption>
                     <p><a href="<?php echo get_author_posts_url( $user->ID ); ?>">view profile</a></p>
                  </figcaption>      

               </figure>
               <h3><?php echo $user->display_name; ?></h3> 
            </div>

            </div>
         <?php
      }
   ?>

Only the ACF field is not working. Any tip on how to fix it?

One more thing: If I use this: <?php the_field('field_name', 'user_1'); ?> works! But this is not what I want, once I need to show a list of users with their respective ACF fields filled.

  • 写回答

1条回答 默认 最新

  • dstwfcz1377 2015-11-16 12:14
    关注

    I could fix it.

    Just use the concatenation with $user->ID under this syntax. So the result is:

    <?php the_field('profile_picture', 'user_'.$user->ID);  ?>
    
    评论

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看