wordpress 程序搭建的网站
一段php代码
需要代码////回复可见/////function reply($content){ if (preg_match_all('/([\s\S]*?)/i', $content, $hide_words)){ $stats = 'hide'; global $current_user; get_currentuserinfo(); if ($current_user->ID) { $email = $current_user->user_email; } else if (isset($_COOKIE['comment_author_email_'.COOKIEHASH])) { $email = $_COOKIE['comment_author_email_'.COOKIEHASH]; } $ereg = "^[_\.a-z0-9]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,5}$"; if (eregi($ereg, $email)) { global $wpdb; global $id; $comments = $wpdb->get_results("SELECT * FROM $wpdb->comments WHERE comment_author_email = '".$email."' and comment_post_id='".$id."'and comment_approved = '1'"); if ($comments) { $stats = 'show'; } } $admin_email = "4531289@qq.com"; //博主Email,博主直接查看 if ($email == $admin_email) { $stats = 'show'; } $hide_notice = '
'; if( $stats == 'show' ){ $content = str_replace($hide_words[0], $hide_words[1], $content); }else{ $content = str_replace($hide_words[0], $hide_notice, $content); } } return $content; } add_filter('the_content', 'reply');打开你的wordpress后台,
找到外观下的编辑菜单,找到右侧的funtion.php
点击打开,然后把上面的代码黏贴到function.php的最后
然后点击更新,在发表博文,在你想要隐藏的某部分内容中加入你要隐藏的内容
最后发布博文,就ok了
第五步需要你使用代码模式中输入