Php Echo$curauth用于作者页面中的用户描述?
例如,我在Wordpress中的一篇文章中有一个作者框:Php Echo$curauth用于作者页面中的用户描述?,php,wordpress,echo,Php,Wordpress,Echo,例如,我在Wordpress中的一篇文章中有一个作者框: $tab = str_repeat("\t", !empty($depth) ? $depth : 0); if (is_single()) { echo "$tab\t\t<p>" . get_the_author_meta('description') . "</p>\n"; $tab=str\u repeat(“\t”,!empty($depth)?$depth:0); if(is_single()){
$tab = str_repeat("\t", !empty($depth) ? $depth : 0);
if (is_single()) {
echo
"$tab\t\t<p>" . get_the_author_meta('description') . "</p>\n";
$tab=str\u repeat(“\t”,!empty($depth)?$depth:0);
if(is_single()){
回声
“$tab\t\t”。获取作者元(“描述”)。“\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; ?> ;
if(是作者()){
//获取作者数据
如果(get_query_var('author_name')):
$curauth=get_user_by('slug',get_query_var('author_name');
其他:
$curauth=get_userdata(get_query_var('author');
endif;
echo“…(这里我需要那行代码的帮助)”;
请原谅我的英语!这应该会让你开始:
<?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
是否已填充用户数据(对象)
更多资讯: