需要将作者“XYZ”设置为所有New Posts. 无论发布内容的实际作者是谁,帖子都应该是saved 作者“XYZ”。
是否有插件或自定义函数可用于此目的?
Note : The existing posts should stay as it is, no \'change of author\' for old posts, only new one should be effected.
需要将作者“XYZ”设置为所有New Posts. 无论发布内容的实际作者是谁,帖子都应该是saved 作者“XYZ”。
是否有插件或自定义函数可用于此目的?
Note : The existing posts should stay as it is, no \'change of author\' for old posts, only new one should be effected.
function wp84782_replace_author( $post_ID )
{
$my_post = array();
$my_post[\'ID\'] = $post_ID;
$my_post[\'post_author\'] = 1 ; //This is the ID number of whatever author you want to assign
// Update the post into the database
wp_update_post( $my_post );
}
add_action( \'publish_post\', \'wp84782_replace_author\' );
更新:此挂钩在发布帖子时运行,而不是在发布后运行,因此该命令试图同时覆盖系统正在执行的操作。所以这里有一个修改版本,取消了之前发布的帖子。如果您希望它永远不允许用户更新作者,也许可以隐藏该元字段。我不知道有一个钩子会在发布帖子后立即运行,但如果有,钩住它可以解决这个问题。function wp84782_replace_author( $post_ID )
{
if(get_post_status( $post_ID ) == \'publish\'){
return;
}
else {
$my_post = array();
$my_post[\'ID\'] = $post_ID;
$my_post[\'post_author\'] = 1 ; //This is the ID number of whatever author you want to assign
// Update the post into the database
wp_update_post( $my_post );
}
}
add_action( \'publish_post\', \'wp84782_replace_author\' );
免责声明:所有这些代码都未经测试,因此可能需要进行少量编辑。我真的想找到一种方法或找到一个插件(可以工作),为一个有多个作者的博客添加不同的rel=author和/或rel=publisher属性。这样,在Google SERP中,我写的一篇文章可能会显示为:Jason Weber Meta Title of that post (my picture) Meta description of that post 而另一个帖子的SERP可能是这样的:Tracy Smith Meta Title of Tracy\'s post (Tra