好了,伙计们,我正在构建一个页面,其中某个子页面有密码保护。在wordpress中很容易。但有一个用户体验问题:当用户输入错误的密码时,没有错误消息或指示密码不正确的内容。
是否可以手动将其编码到模板文件中?
好了,伙计们,我正在构建一个页面,其中某个子页面有密码保护。在wordpress中很容易。但有一个用户体验问题:当用户输入错误的密码时,没有错误消息或指示密码不正确的内容。
是否可以手动将其编码到模板文件中?
不太可能,但可以尝试以下方式:
add_action(\'wp\', \'check_post_pass\');
function check_post_pass(){
if(!is_single() || !post_password_required()) return;
global $post;
if(isset($_COOKIE[\'wp-postpass_\'.COOKIEHASH])
&& $_COOKIE[\'wp-postpass_\'.COOKIEHASH] !== $post->post_password){
define(\'INVALID_POST_PASS\', true);
// tell the browser to remove the cookie so the message doesn\'t show up every time
setcookie(\'wp-postpass_\'.COOKIEHASH, NULL, -1, COOKIEPATH);
}
}
在模板中:if(defined(\'INVALID_POST_PASS\')) _e(\'The password you entered is funky\');
但更好的办法是创建自己的the_content()
-喜欢函数和密码表单+检查函数,没有cookie。。。我已经知道了here 如何在wordpress admin中从posts表中删除行操作。现在,我想在pages表中执行同样的操作。我查过核心文件,但我就是不明白。任何人下面是函数中使用的代码。php删除帖子中的行操作:function remove_row_actions( $actions ) { if( get_post_type() === \'post\' ) unset( $actions[\'edit\'] ); unse