wordpress - WordPress 片段 - 发布密码保护检查
问题描述
您好,我想运行内容修改片段,但仅限于受密码保护的帖子。
function func($content) {
if( $post->password_protected ){
$content = [whatever]
}
return $content;
}
add_filter('the_content', 'func');
我该如何进行密码保护检查?
解决方案
我想到了
if( !empty($GLOBALS['post']->post_password) ){..}
推荐阅读
- python - 如何测量在 TKInter 画布上绘制的线条长度?
- android - android studio中已经存在的程序类型
- c# - 将 DataRow 复制到新的 DataTable 中,并使用原始 DataTable 中的适当类型
- firebase - 如何对firebase中的数据进行排序?在颤振应用程序中
- unreal-engine4 - 在虚幻中,我无法修改 bUseControllerRotation[Pitch | 偏航 | Roll] 在构造函数处
- python - 用于解码使用 DataKey 加密的轨道数据的 python 脚本
- node.js - 邮递员无法使用 s3 预签名 url 上传文件
- android - 在单独的方法中设置时 onClickListener 的性能较慢
- python - 使用 Python re.sub 进行基于位置的替换
- python - 如何使用 djnago 表单更新 Django 模型中的 ImageField?