作者页面中用户描述的回显$curauth



例如,我在Wordpress的单个帖子中为作者框提供了这个:

$tab = str_repeat("t", !empty($depth) ? $depth : 0);
if (is_single()) {
echo
"$tabtt<p>" .  get_the_author_meta('description') . "</p>n";

然后我想制作一个这样的代码来在作者页面上工作,我有以下代码:

if (is_author()) {
            // Get author data
            if(get_query_var('author_name')) :
                $curauth = get_user_by('slug', get_query_var('author_name'));
            else :
                $curauth = get_userdata(get_query_var('author'));
            endif;
        echo "...(here i need help for that line of code)" <?php echo $curauth->description; ?> ;

请原谅我的英语!

这应该让你开始:

<?php
if ( is_author() ) {
    $curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
    if( $curauth != false ) {
        echo $curauth->description;
    } else {
        echo 'Could not get WP_User object';
    }
}
?>

或页面上的某个位置

<p>Author name:<?php echo $curauth->nickname; ?></p>
<p>Author description: <?php echo $curauth->description; ?></p>

在尝试回显任何数据之前,请始终检查$curauth是否已填充用户数据(WP_User对象)。

更多信息: http://codex.wordpress.org/Author_Templates

最新更新