本文最后更新于2015年9月1日,因长期没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
WordPress 默认的密码提示文字是这样的:This post is password protected. To view it please enter your password below:。是的,纯英文。如果你的不是,应该是你用的主题比较人性化,给你做好了。下面的代码就是可以让你自定义WordPress 密码文章提示文字。
在当前主题的functions.php 文件中添加以下代码:
//自定义WordPress密码文章提示文字 andykwok.cc add_filter( 'the_password_form', 'dw_custom_password_form' ); function dw_custom_password_form() { global $post; $label = 'pwbox-'.( empty( $post->ID ) ? rand() : $post->ID ); $o = '<form class="protected-post-form" action="' . get_option('siteurl') . '/wp-login.php?action=postpass" method="post"> ' . __( "<p>密码保护文章,你必须输入正确的密码才能访问:</p>" ) . ' <label for="' . $label . '">' . __( "Password:" ) . ' </label><input name="post_password" id="' . $label . '" type="password" size="20" /><input type="submit" name="Submit" value="' . esc_attr__( "Submit" ) . '" /> </form> '; return $o; }
评论前必须登录!
注册