有的投稿类网站需要网站WordPress主题能够调用活跃会员列表,活跃作者列表.
这样可以吸引作者的活跃度,也能让WordPress主题变得更有吸引力.
我们可以实现调用活跃作者列表,然后点击该头像可以跳转到她写的文章列表
但是不能把注册用户调用出来,如何治调用作者的WordPress头像墙?
这个需要先看看这篇文章: WordPress主题开发教程:给注册用户按权限等级区分
下面是代码放在你要显示的WordPress主题位置可以实现WordPress照片墙效果:
<?php global $wpdb; 所有作者 $authors = $wpdb->get_results("SELECT ID, user_login from $wpdb->users ORDER BY display_name"); //除了admin外的作者 //$authors = $wpdb->get_results("SELECT ID, user_login from $wpdb->users WHERE user_login <> 'admin' ORDER BY display_name"); //管理员和编辑 $authors = $wpdb->get_results("SELECT ID, user_login from $wpdb->users , $wpdb->usermeta WHERE meta_key = 'wp_user_level' AND meta_value >= 7 AND ID = user_id ORDER BY display_name"); foreach ($authors as $author) { //修改过固定链接 echo "<div>"; //默认链接 //echo "<div><a href='".get_bloginfo('url')."?author=".$author->ID."'>".get_avatar($author->ID,50)."</a>"; //新浪微博 if(get_the_author_meta('weibo_sina', $author->ID)){ echo "<a href='".get_the_author_meta('weibo_sina', $author->ID)."'>".get_avatar($author->ID,50)."</a>"; } //个人网站 elseif(get_the_author_meta('url', $author->ID)){ echo "<a href='".get_the_author_meta('url', $author->ID)."'>".get_avatar($author->ID,50)."</a>"; }else { echo "<a href='".get_bloginfo('url')."/author/".get_the_author_meta('user_login', $author->ID)."'>".get_avatar($author->ID,50)."</a>"; } //个人说明 if(get_the_author_meta('description', $author->ID)){ echo get_the_author_meta('description', $author->ID); } echo "</div>"; } ?>