WordPress - wp_list_authors获取多个作者gravatar和bio

时间:2009-10-25 08:21:31

标签: wordpress wordpress-theming

我和多个用户一起运行WordPress博客。我创建了authorlist.php模板以显示页面中的所有作者列表。

我的模板代码是

<?php
/*
Template Name: Author List
*/
?>


<?php get_header(); ?>

<div id="main">
    <div id="pageleft">

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>

<div class="main-page-container">
    <div class="page-top"></div>
    <div class="page-container">
            <div class="authors-list">
                <h1><?php the_title(); ?></h1>
<?php wp_list_authors('optioncount=1'); ?>
            </div>
            <div class="clear">
            </div>
        </div>
    <div class="page-bottom">
    </div>


<?php endwhile; ?>

<?php else : ?>

<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>

<?php endif; ?>

 <!--/index-->
<br />
 <?php get_footer(); ?>

我使用了wp_list_authors,所以没有选项可以显示每个用户的gravatar和传记。我想展示它。有机会帮我吗?谢谢。对不起,我的英语不好。

关心,

3 个答案:

答案 0 :(得分:4)

有点晚了,没有自己动手解决方案,但有这个问题的其他人可能想查看Author Avatars插件以获取此功能。

答案 1 :(得分:0)

嘿伙伴,看看下面的链接,我使用了这个方法,现在有一个作者列表,其中包含每个作者博客页面和作者简介的gravatars,bio和个别链接。

WordPress MU Forums Plugins and Hacks - List Authors

答案 2 :(得分:0)

抱歉,我无法直接浏览它,所以刚刚发布了我的整个模板。

<?php
/*
Template Name: standard
 */

get_header(); ?>
<!-- This sets the $curauth variable -->

    <?php
    if(isset($_GET['author_name'])) :
        $curauth = get_userdatabylogin($author_name);
    else :
        $curauth = get_userdata(intval($author));
    endif;

    $curID = $curauth->ID;




    ?>
<div id="toolbarWrap">
    <div id="toolbarContainer" class="container_12">

        <div id="pageTitle" class="grid_12">
            <div id="roundedH1">                
                <b class="b1f"></b><b class="b2f"></b><b class="b3f"></b><b class="b4f"></b>

              <div class="contentf">
                <div><h1>Staff Profile</h1></div>
              </div>

              <b class="b4f"></b><b class="b3f"></b><b class="b2f"></b><b class="b1f"></b>
            </div>
        </div><!-- /pageTitle -->


        <div class="clear"></div>

        <div id="tabRowWrap" class="grid_12">

                    <?php include(TEMPLATEPATH . '/modules/breadcrumb.php'); ?>

        </div><!-- /tabRowWrap -->
    </div><!-- / toolbarContainer -->

</div><!-- /toolbarWrap -->

<div id="mainContent" class="container_12">
    <div class="padTop">

    <div id="leftColumn" class="grid_9">

    <div id="panes">

        <div id="post">

            <div class="tabContent">
            <div class="author-profile vcard">
            <div class="grid_2 alpha">
                <?php echo get_avatar($curauth->user_email, '120', $avatar); ?>


        <?php


        $fullname = get_the_author_meta('first_name',$curID) + ' ' + get_the_author_meta('last_name',$curID);
        $firstname = get_the_author_meta('first_name',$curID);
        $nickname = get_the_author_meta('nickname',$curID);
        $position = get_the_author_meta('position',$curID);
        $hobbies = get_the_author_meta( 'hobbies',$curID );
        $interests = get_the_author_meta( 'interests',$curID );
        $modals = get_the_author_meta( 'modals',$curID );
        $bio = get_the_author_meta( 'description',$curID );

        $favfood = get_the_author_meta( 'favfood',$curID );
        $song = get_the_author_meta( 'song',$curID );
        $flower = get_the_author_meta( 'flower',$curID );
        $pet = get_the_author_meta( 'pet',$curID );
        $drink = get_the_author_meta( 'drink',$curID );
        $favitem = get_the_author_meta( 'favitem',$curID );
        $favsnack = get_the_author_meta( 'favsnack',$curID );
        $favmovie = get_the_author_meta( 'favmovie',$curID );
        $favactor = get_the_author_meta( 'favactor',$curID );
        $motherquote = get_the_author_meta( 'motherquote',$curID );

        ?>

            </div>

            <div class="grid_7 omega">
                <!-- Name and links -->
                <div class="tabTitle">
                    <h2><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></h2><br />
                    <h3><?php the_author_meta('position',$curID); ?></h3>
                </div>
                <td><p class="authorLinks"><a href="<?php bloginfo('url'); ?>/therapist-blogs/<?php echo $curauth->first_name; ?>-<?php echo $curauth->last_name; ?>">Blog</a> - <a href="mailto:<?php echo $curauth->user_email; ?>">Email</a></p>
                <div class="clear"></div>
                <br />

                <!-- Description -->
                <?php if ($description) { ?>
                    <tr>
                <th><h4>Bio:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $description; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- Interests -->
                <?php if ($interests) { ?>
                    <tr>
                <th><h4>Interests:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $interests; ?>

                       </tr>
                </p></td>
                <?php }; ?>

                <!-- Modals -->
                <?php if ($modals) { ?>
                    <tr>
                <th><h4>Modalities:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $modals; ?>

                     </tr>
               </p></td>
                <?php }; ?>

                <!-- Hobbies -->
                <?php if ($hobbies) { ?>
                    <tr>
                <th><h4>Hobbies:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $hobbies; ?>

                </p></td>
                     </tr>
               <?php }; ?>

            <h3>60 Seconds with <?php echo $nickname; ?></h3>


            <table class="quickProfile-Table">

                <!-- favfood -->
                <?php if ($favfood) { ?>
                    <tr>
                <th><h4>Favourite Food:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $favfood; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- song -->
                <?php if ($song) { ?>
                    <tr>
                <th><h4>Favourite Song:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $song; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- flower -->
                <?php if ($flower) { ?>
                    <tr>
                <th><h4>Favourite Flower:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $flower; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- pet -->
                <?php if ($pet) { ?>
                    <tr>
                <th><h4>Favourite Pet:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $pet; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- drink -->
                <?php if ($drink) { ?>
                    <tr>
                <th><h4>Favourite Drink:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $drink; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- favitem -->
                <?php if ($favsnack) { ?>
                    <tr>
                <th><h4>Favourite Snack:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $favsnack; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- favmovie -->
                <?php if ($favmovie) { ?>
                    <tr>
                <th><h4>Favourite Movie:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $favmovie; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- favactor -->
                <?php if ($favactor) { ?>
                    <tr>
                <th><h4>Favourite Actor:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $favactor; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- favitem -->
                <?php if ($favitem) { ?>

                <th><h4>Favourite thing to spend money on:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $favitem; ?>

                </p></td>
                    </tr>
                <?php }; ?>

                <!-- motherquote -->
                <?php if ($motherquote) { ?>
                    <tr>
                <th><h4>Something your mother always said:</h4></th>
                <td><p class="author-description author-bio">                    

                    <?php echo $motherquote; ?>

                </p></td>
                    </tr>
                <?php }; ?>

            </table>


                <!-- Posts -->

                <h3>Posts by <?php echo $curauth->nickname; ?>:</h3>
                <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

                <ul>
                  <li>
                      <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
                      <?php the_title(); ?></a>,
                      <?php the_time('d M Y'); ?> in <?php the_category('&');?>
                  </li>
                </ul>

                <?php endwhile; else: ?>
                <h3><?php _e('Sorry, no posts matched your criteria.'); ?></h3>
                <?php endif; ?>

            </div><!-- end grid_7 -->       
            </div><!-- end author-profile vcard -->
            </div>


        </div><!-- /post -->
            <hr />



    </div><!-- /panes -->

    <div class="clear"></div>


    </div><!-- /leftcolumn-->



<?php get_sidebar(); ?>



</div><!-- /Padtop -->
    <div class="clear"></div>
</div><!--/mainContent-->

    <div class="clear"></div>
<div id="footer">

    <div id="footerToolbar">

    </div><!-- /footerToolbar -->

    <div id="footerMain">

    </div><!-- /footerMain -->


</div><!--/footer-->

</div><!-- /page-container -->
<div id="lowerSpacer">
<div class="loveLink"><a href="http://www.publikdesign.com" target="_blank" title="Website and graphic design on Phillip Island">Website designed and developed by Publik Design</a></div>
</div>
<div id="contactOverlay" class="simple_overlay">
    <div class="overlayContent">
        <div class="overlayHeaderBG">
          <div class="overlayHeader">
          <h3>Contact Us</h3>
          </div><!-- /overlayHeader -->
        </div><!-- /overlayHeaderBG -->

        <div class="overlayBody">
        <p>Please take the time to fill out this form and we will get back to you as soon as possible.</p>

        <div id="webform">
        <form>

          <label for="user">Name</label>

          <input type="text" name="user" value=""><br />

          <label for="emailaddress">Email Address:</label>
          <input type="text" name="emailaddress" value="" /><br />

          <label for="comments">Comments:</label>
          <textarea name="comments"></textarea><br />

          <label for="terms">Agree to Terms?</label>
          <input type="checkbox" name="terms" class="boxes" /><br />

          <input type="submit" name="submitbutton" id="submitbutton" value="Submit" />

        </form>
        </div>

        </div><!-- /overlayBody -->

    </div><!-- /overlayContent -->
</div><!--/contactOverlay -->

</body>
</html>