如何删除wordpress 评论框
首先到www.poedit.net下截Windows版的 poedit一、依次打开wp-content\languages\themes找到你主题用的 .po 文件 例如我用的是twentyten主题相对应的.po文件就是 twentyten-zh_CN.po 然后用poedit打开.po 查找到 “你要改的文字” 改成你想要的文字 最后保存编译文件就可以了二、依次打开wp-content\languages按上面的操作编辑 admin-zh_CN.po和zh_CN.po 文件就可以了
有没有给wordpress评论点赞然后自动置顶的代码
先判断下是否登录,然后获取当前用户对象,然后获取当前用户对象的信息,需要哪些用哪些:if(is_user_logged_in()){$current_user = wp_get_current_user();/*** @example Safe usage: $current_user = wp_get_current_user();* if ( !($current_user instanceof WP_User) )* return;*/echo 'Username: ' . $current_user->user_login . '';echo 'User email: ' . $current_user->user_email . '';echo 'User first name: ' . $current_user->user_firstname . '';echo 'User last name: ' . $current_user->user_lastname . '';echo 'User display name: ' . $current_user->display_name . '';echo 'User ID: ' . $current_user->ID . '';}
如何修改wordpress默认的评论框
展开全部 有以下3种方法来实现“免插件仅代码实现WordPress评论回复邮件提醒”,都是把代码加到主题里的functions.php中的最后一个 ?> 即可。
第一种:所有回复都发邮件通知使用前,请确定你的主机是否支持 mail() 函数。
/* comment_mail_notify v1.0 by willin kan. (所有回复都发邮件) */function comment_mail_notify($comment_id) { $comment = get_comment($comment_id); $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; $spam_confirmed = $comment->comment_approved; if (($parent_id != '') && ($spam_confirmed != 'spam')) { $wp_email = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME'])); //e-mail 发出点, no-reply 可改为可用的 e-mail. $to = trim(get_comment($parent_id)->comment_author_email); $subject = '您在 [' . get_option("blogname") . '] 的留言有了回复'; $message = ' ' . trim(get_comment($parent_id)->comment_author) . ', 您好! 您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:' . trim(get_comment($parent_id)->comment_content) . ' ' . trim($comment->comment_author) . ' 给您的回复:' . trim($comment->comment_content) . ' 您可以点击 查看回复完整内容 欢迎再度光临 ' . get_option('blogname') . ' (此邮件由系统自动发送,请勿回复.) '; $from = "From: "" . get_option('blogname') . "" "; $headers = "$fromnContent-Type: text/html; charset=" . get_option('blog_charset') . "n"; wp_mail( $to, $subject, $message, $headers ); //echo 'mail to ', $to, ' ' , $subject, $message; // for testing }}add_action('comment_post', 'comment_mail_notify');// -- END - 第二种:让访客自己选择是否邮件通知在评论框下方显示一个勾选框,让评论人自己决定是否接收邮件通知。
不过要注意的是,具体的#comment_mail_notify 需要你自己定义css以符合你的主题样式。
function comment_mail_notify($comment_id) { $admin_notify = '1'; // admin 要不要收回复通知 ( '1'=要 ; '0'=不要 ) $admin_email = get_bloginfo ('admin_email'); // $admin_email 可改为你指定的 e-mail. $comment = get_comment($comment_id); $comment_author_email = trim($comment->comment_author_email); $parent_id = $comment->comment_parent ? $comment->comment_parent : ''; global $wpdb; if ($wpdb->query("Describe {$wpdb->comments} comment_mail_notify") == '') $wpdb->query("ALTER TABLE {$wpdb->comments} ADD COLUMN comment_mail_notify TINYINT NOT NULL DEFAULT 0;"); if (($comment_author_email != $admin_email && isset($_POST['comment_mail_notify'])) || ($comment_author_email == $admin_email && $admin_notify == '1')) $wpdb->query("UPDATE {$wpdb->comments} SET comment_mail_notify='1' WHERE comment_ID='$comment_id'"); $notify = $parent_id ? get_comment($parent_id)->comment_mail_notify : '0'; $spam_confirmed = $comment->comment_approved; if ($parent_id != '' && $spam_confirmed != 'spam' && $notify == '1') { $wp_email = 'no-reply@' . preg_replace('#^www.#', '', strtolower($_SERVER['SERVER_NAME'])); // e-mail 发出点, no-reply 可改为可用的 e-mail. $to = trim(get_comment($parent_id)->comment_author_email); $subject = '您在 [' . get_option("blogname") . '] 的留言有了回复'; $message = ' ' . trim(get_comment($parent_id)->comment_author) . ', 您好! 您曾在《' . get_the_title($comment->comment_post_ID) . '》的留言:' . trim(get_comment($parent_id)->comment_content) . ' ' . trim($comment->comment_author) . ' 给您的回复:' . trim($comment->comment_content) . ' 您可以点击查看回复的完整内容 还要再度光临 ' . get_option('blogname') . ' (此邮件由系统自动发送,请勿回复.) '; $from = "From: "" . get_option('blogname') . "" "; $headers = "$fromnContent-Type: text/html; charset=" . get_option('blog_charset') . "n"; wp_mail( $to, $subject, $message, $headers ); //echo 'mail to ', $to, ' ' , $subject, $message; // for testing }}add_action('comment_post', 'comment_mail_...
转载请注明出处51数据库 » wordpress评论框代码
Mummmmmm