首页» 教程» Wordpress教程» WordPress 定时关闭评论-用户交互(六十八)

WordPress 定时关闭评论-用户交互(六十八)

Hello,嗨,大家好,我是哈喽猿。

这里是哈喽猿网

今天推送的是wordpress教程的文章,感谢您宝贵的时间阅读

设置在WordPress的背景-讨论中,我们可以设置在几天后自动关闭已发表的文章评论:

WordPress 定时关闭评论

但是,用户不知道文章何时会关闭注释,因此我们可以在注释表单的顶部添加提示:

WordPress 定时关闭评论

要做到这一点,只需将以下代码添加到当前主题的Functions.php中:

/** * WordPress 告知用户评论关闭的时间 * https://www.wpdaxue.com/automatic-comment-closing.html */ add_action( 'comment_form_top', 'wpdx_comment_closes_in' ); function wpdx_comment_closes_in() { global $post; if ($post->comment_status == 'open') { $close_comments_days_old = get_option( 'close_comments_days_old' ); $expires = strtotime( "{$post->post_date_gmt} GMT" ) + $close_comments_days_old * DAY_IN_SECONDS; printf( __( '(该文章的评论功能将在 %s 后关闭)', 'domain' ), human_time_diff( $expires )); } }

发表评论

0 评论

提供最优质的资源集合

站长留言