FWQ
如何在WordPress 文章未尾自动添加一个作者信息框
下面由/” target=”_blank”>wordpress教程栏目给大家介绍在wordpress 文章未尾自动添加一个作者信息框的方法,希望对需要的朋友有所帮助! 如果想在文章的末尾,添加文章作者的相关信息,下面一段代码可以方便在文章中添加一个作者的信息框。 将代码添加到当前主题functions.php中: function wp_author_info_box( $content ) { global $post; // 检测文章与文章作者 if ( is_single() && isset( $post->post_author ) ) { // 获取作者名称 $display_name = get_the_author_meta( 'display_name', $post->post_author ); // 如果没有名称,使用昵称 if ( empty( $display_name ) ) $display_name = get_the_author_meta( 'nickname', $post->post_author ); // 作者的个人信息 $user_description = get_the_author_meta( 'user_description', $post->post_author ); // 获取作者的网站 $user_website = get_the_author_meta('url', $post->post_author); // 作者存档页面链接 $user_posts = get_author_posts_url( get_the_author_meta( 'ID' , $post->post_author)); if ( ! empty( $display_name ) ) $author_details = '<div>关于 ' . $display_name . '</div>'; if ( ! empty( $user_description ) ) // 作者头像 $author_details .= '<div>' . get_avatar( get_the_author_meta('user_email') , 90 ) . nl2br( $user_description ). '</div>'; $author_details .= '<div> <a>查看 ' . $display_name . ' 所有文章</a>'; // 检查作者在个人资料中是否填写了网站…