Monstroid. 如何添加评论自定义帖子
2015年11月18日
本教程将展示如何启用 自定义帖子的评论 in Monstroid themes.
Monstroid. 如何添加评论自定义帖子在本教程中,您将学习如何为团队帖子启用注释.
为了启用自定义帖子的评论,您需要选中 允许评论 option on Edit Post page. 当缺少此选项时 Editor 页,需要额外的代码.
-
复制启用注释所需的代码 http://gist.github.com/cheh/ec191fce0d397e10f77f 或者从下面复制:
//为团队单篇文章添加' comments '支持功能. Add_filter ('cherry_team_post_type_args', 'cherry_child_add_comments_support'); cherry_child_add_comments_support($args) { if ( ! 空($args['supports'])) { $args['supports'][] = 'comments'; } 返回参数美元; } /** *加载评论模板在单个团队的帖子. * @see do_action('cherry_post_after') - hook in plugins/cherry-XXXX/templates/single-XXXX.php file. */ Add_action ('cherry_post_after', 'cherry_child_load_comments_template', 25); 函数cherry_child_load_comments_template() { $post_type = get_post_type(); If ('team') !== $post_type) { return; } if ( ! Is_singular ($post_type) { return; } If (comments_open() || get_comments_number()) { comments_template(' /模板/评论.Php ', true); } }
-
接下来,导航到 Appearance -> Editor,在themeXXXXX下选择 functions.php 要编辑的文件. 粘贴所需的代码在底部 functions.php file.
-
要检查更改,请转到 Team tab 在管理面板中,打开任何帖子并向下滚动以查找 允许注释 option. 检查一下 update the post:
-
用Ctrl/Cmd+F5刷新前端以查看更改. 评论表单将出现在页面上:
请随时查看下面的详细视频教程:
Monstroid. 如何添加评论自定义帖子