我正在编写自己的插件。
工作原理如下:
function myfunc (){
$a = \'hello\';
// the sentence what Am looking for:
if ( user is logged and is the author of current post / page ){
$a= \'author\';
}
return $a;
}
想知道我怎样才能做到这一点?我正在编写自己的插件。
工作原理如下:
function myfunc (){
$a = \'hello\';
// the sentence what Am looking for:
if ( user is logged and is the author of current post / page ){
$a= \'author\';
}
return $a;
}
想知道我怎样才能做到这一点?只需比较显示名称:
$currentuser = get_currentuserinfo();
if ( get_the_author() == $currentuser->displayname ) {
// current user is the post author; do something
}
Theget_the_author()
函数返回displayname
, 应该能够与displayname
参数,该参数是$currentuser
对象您可以使用current\\u user和post变量获取此信息。
function myfunc (){
global $current_user, $post;
$a = \'hello\';
// check if current user id matches post author id
if ( $current_user->ID == $post->post_author ){
$a = \'author\';
}
return $a;
}
在为我们正在创建的站点开发环境时,我遇到了一个奇怪的问题。我们有自定义的帖子类型,所以我不确定这是否是它不能正常工作的原因。然而,我设法让帖子一次显示5条,而不是正常的10条。然而,在其中一个类别中,它只显示20个帖子中的10个。奇怪的是,如果我转到另一个类别,它会正确运行。 <?php echo category_description(); ?> <?php if (have_posts()) : ?> <?php $i = 0; while (