2013-10-29 27 views
0

我試圖展現在我的WordPress網站的主頁文章作者的化身,現在它顯示使用下面的代碼如何顯示wordpress的化身在PHP

<article> 
     <header> 
     <div class="date"><?php the_time('M') ?><br /><span class="day"><?php the_time('j') ?></span><br /><?php the_time('Y') ?></div> 
     <div class="category"><?php the_category(' // ') ?></div> 
     <h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1> 
     </header> 
     <?php if(of_get_option("alltuts_posts_layout")==0) { ?> 
     <div class="postThumb"><a href="<?php the_permalink() ?>"><?php the_post_thumbnail(); ?></a></div> 
     <div class="textPreview"> 
      <?php the_excerpt(); ?> 
     </div> 
     <?php } else { ?> 
      <?php the_content(''); ?> 
     <?php } ?> 
     <footer> 
      <a href="<?php the_permalink() ?>" class="more-link"><?php _e('Continue Reading ', 'site5framework'); ?>&raquo;</a> 
      <div class="metaRight"> 
       <img src="<?php bloginfo('template_directory'); ?>/images/ico_author.png" alt="<?php _e('Author', 'site5framework'); ?>"/> <?php _e('An article by ', 'site5framework'); ?> <?php the_author_link(); ?> 
       <img src="<?php bloginfo('template_directory'); ?>/images/ico_comments.png" alt="<?php _e('Comments', 'site5framework'); ?>"/> <?php comments_popup_link(__("No Comments", "site5framework"),__("1 Comment", "site5framework"),__("% Comments", "site5framework"));?> 
      </div> 
     </footer> 
    </article> 

所有作者共同的圖標,請看到正在運行的代碼here

在此先感謝

回答

0

顯示WordPress的作者頭像將使用由的gravatar(http://www.gravatar.com/)提供的服務最簡單的方法。

Wordpress提供了一個名爲get_avatar的功能,允許您爲提供的用戶或電子郵件地址獲取頭像。

這裏有你需要改變什麼的例子:

替換:

<img src="<?php bloginfo('template_directory'); ?>/images/ico_author.png" alt="<?php _e('Author', 'site5framework'); ?>"/> 

有了:

<?php echo get_avatar(get_the_author_meta('user_email'), 32);?> 
+0

提供強大的支持,感謝garbetjie – user2923383