wp/wordpress用户中心页面的一些函数调用记录!
七娃博客1,152人阅读
本篇整理一些用户中心常用的函数调用使用的方法,可能没有整理完整,后续补充吧!
调用 用户名 get_the_author()
<?php echo get_the_author() ?>
调用用户头像 get_avatar($a,num),第一个参数必须是 用户/用户id/邮箱,第二个是头像大小
根据当前作者邮箱调用用户头像
<?php echo get_avatar( get_the_author_meta('email'), '200' );?>
根据用户id
<?php echo get_avatar(1, 50); ?> <?php echo get_avatar('email@example.com', 50); ?>
用户简介
<?php if(get_the_author_meta('description')){ echo the_author_meta( 'description' );}else{echo'这个人有点懒,啥都没有写!'; }?>
获取指定作者的文章列表网址 get_author_posts_url()
例如:在首页循环中,调用作者及作者用户中心的链接
<a class="author-name" href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ) ?>"><?php echo get_the_author() ?></a>
评论 | 0 条评论
登录之后才可留言,前往登录