链接到wp用户查询中的用户配置文件

时间:2017-04-12 09:45:23

标签: wordpress loops

我正在尝试创建一个人员目录,以显示所有WP用户,然后允许您点击并查看他们的个人资料,类似于标准的自定义帖子循环,然后查看单个{customPost} .php。

下面是我为我的用户设置的循环,但iv为循环创建了我的模板,但是我正在努力如何输出链接以点击查看用户个人资料?

<?php

    // WP_User_Query arguments
    $args = array(
        'order'          => 'ASC',
        'orderby'        => 'id',
    );

    // The User Query
    $user_query = new WP_User_Query( $args );

    // The User Loop
    if ( ! empty( $user_query->results ) ) {
        foreach ( $user_query->results as $user ) { ?>
        <li><a href="">User Name</a>
        </li>

2 个答案:

答案 0 :(得分:0)

这应该有效,

尝试将$ user_ID全局变量传递给以下函数,

<?php 
  global $user_ID;
  if ( get_the_author_meta('user_url',$user_ID) ) : // If a user has filled out their decscription show a bio on their entries 
?>
  <a class="meta-website" href="<?php the_author_meta('user_url',$user_ID); ?>">Author's Website</a>    
<?php endif; ?>

答案 1 :(得分:0)

感谢@Prabu,这已经解决了。以下对我有用:

<?php echo get_author_posts_url( $user->id ); ?>"><?php the_author_meta( 'user_url', $user->id ); ?></a>

然后我在单个作者页面上遇到问题,抛出了404,但可以看到这是一个固定链接问题。

相关问题