在WordPress 文章未尾自动添加一个作者信息框

如果想在WordPress文章的末尾,添加文章作者的相关信息,下面一段代码可以方便在文章中添加一个作者的信息框。

将代码添加到当前主题functions.php中:

  1.  wp_author_info_box(  ) {
  2.      ;
  3.     
  4.      ( is_single() && isset( ->post_author ) ) {
  5.         
  6.          = get_the_author_meta( \’display_name\’, ->post_author );
  7.         
  8.          ( (  ) )
  9.          = get_the_author_meta( \’nickname\’, ->post_author );
  10.         
  11.          = get_the_author_meta( \’user_description\’, ->post_author );
  12.         
  13.          = get_the_author_meta(\’url\’, ->post_author);
  14.         
  15.          = get_author_posts_url( get_the_author_meta( \’ID\’ , ->post_author));
  16.          ( ! (  ) )
  17.          = \'<div =>关于 \’ .  . \'</div>\’;
  18.          ( ! (  ) )
  19.         
  20.          .= \'<div =>\’ . get_avatar( get_the_author_meta(\’user_email\’) , 90 ) . (  ). \'</div>\’;
  21.          .= \'<div =><a href=>查看 \’ .  . \’ 所有文章</a>\’;
  22.         
  23.          ( ! (  ) ) {
  24.         
  25.          .= \’ | <a href= target= rel=>网站</a></div>\’;
  26.         }  {
  27.             
  28.              .= \'</div>\’;
  29.         }
  30.         
  31.          =  . \'<footer = >\’ .  . \'</footer>\’;
  32.     }
  33.      ;
  34. }
  35. add_action( \’the_content\’, \’wp_author_info_box\’ );
  36. remove_filter(\’pre_user_description\’, \’wp_filter_kses\’);

再将配套的CSS添加到主题样式文件style.css中:

  1. .author-bio-section {
  2.     : ;
  3.     : ;
  4.     : 100%;
  5.     :  0;
  6.     : ;
  7.     :   ;
  8. }
  9. .author-name {
  10.     : ;
  11.     : ;
  12.     : 0 0  0;
  13. }
  14. .author-details img {
  15.     : ;
  16.     : ;
  17.     : ;
  18.     :   0 0;
  19. }

最终效果:

源代码出处
    © 版权声明
    THE END
    喜欢就支持一下吧
    点赞0 分享
    评论 抢沙发

    请登录后发表评论

      暂无评论内容