我想添加一个特殊的隐藏标记,为未注册用户隐藏帖子页面产品文本,并显示一个短语,如“阅读全文-请注册”。为此,我创建了一个微型插件。但它不起作用。
function hide_replace_register( $content ) {
if (!is_user_logged_in()) {
$updated_content = explode("<!--hide-->", $content);
$updated_content = explode("<!--hide-->", $content);
$updated_content = explode("<!–hide–>", $content);
$ucontent = $updated_content[0];
if ($ucontent !== $content) {
$ucontent .= \'<a href="\' . wp_registration_url() .\'"><strong>To read a full article text - please, Register!</strong></a>\';
} else {
$ucontent = $content;
}
return $ucontent;
}
}
add_filter(\'the_content\', \'hide_replace_register\', 10);
你能帮我纠正错误吗?