首页 > 解决方案 > WordPress 片段 - 发布密码保护检查

问题描述

您好,我想运行内容修改片段,但仅限于受密码保护的帖子。

function func($content) {

   if( $post->password_protected ){
      $content = [whatever]
   }

   return $content;
}
add_filter('the_content', 'func');

我该如何进行密码保护检查?

标签: wordpresscode-snippets

解决方案


我想到了

if( !empty($GLOBALS['post']->post_password) ){..}

推荐阅读