截图:
这是日志中重复错误的摘录:
[2022-04-16 00:08:52] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"}
[2022-04-16 00:09:06] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"}
[2022-04-16 00:09:08] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"}
[2022-04-16 00:09:50] comment_formatter.ERROR: format.missing_post_data {"keys":"discourse_permalink,discourse_comments_raw"}
当我发表新帖子时,它可以正常工作,并且会创建主题。但是,当在 Discourse 中发表评论时,它不会同步到 WordPress。
我没有做太多更改,您可以看到上面的设置。有什么想法是我做错了什么或者遗漏了什么吗?
我遵循了这里的指南:
编辑:
我遇到了同样的错误,但在论坛上,这是唯一的搜索结果:
comment_formatter.ERROR: format.missing_post_data
这是一个已知问题吗?还是可以解决?
1 个赞
您好 Angus,
- 是的,当然可以:60 Linux Networking commands and scripts (这是目前唯一同步的帖子)
- 我在尝试了数小时但仍未完全奏效后,才作为最后的手段检查了 Ajax。我现在已取消勾选 Ajax。我猜没有 Webhook,同步间隔会花费很长时间。
现在似乎可以工作了,但格式有点不够优雅。我猜我必须弄清楚 CSS?
另外,有没有办法为旧的 WP 博文显示“加入讨论”类型的链接到我们的 Discourse 论坛主页?换句话说,如果没有帖子的评论,或者帖子之前没有同步到 Discourse,那么插件将添加一个指向我的 Discourse 论坛主页的常规链接,而不是留空。
非常感谢您的帮助。
1 个赞
angus
(Angus McLeod)
4
是的,它的显示方式取决于您的主题。插件本身只有很少的样式。
“加入讨论”链接不会出现在未链接的主题上。不过,您可以通过在主题的 functions.php 文件中使用 comments_template 过滤器自行添加类似内容。我没有测试过这段代码,但类似这样的代码应该可以工作:
use WPDiscourse\Utilities\Utilities as DiscourseUtilities;
function non_discourse_comments_template( $comment_template ) {
global $post;
$post_id = $post->ID;
$discourse_post_id = get_post_meta( $post_id, 'discourse_post_id', true );
if ($discourse_post_id) {
return;
} else {
$options = DiscourseUtilities::get_options();
$discourse_permalink = $options['url'];
$link_text = "Join the Discussion";
return '<div class="wpdc-join-discussion"><a class="wpdc-join-discussion-link" href="' . esc_url_raw( $discourse_permalink ) . '" target="_blank" rel="noreferrer noopener">' . esc_html( $link_text ) . '</a></div>';
}
}
add_filter( "comments_template", "non_discourse_comments_template" );
2 个赞
angus
(Angus McLeod)
拆分了此话题
5
4 篇帖子已拆分为新主题:日志中的评论格式化程序错误
再次感谢您的额外帮助和指导!
我一直在阅读和搜索 CSS 来粘贴,以稍微改善布局。
但是,由于我对 CSS/样式不熟悉(除了粘贴现有的 CSS),我想对导入的评论的样式进行非常基本的修改。即,在评论中的 discourse 用户名旁边使用较小的头像图片,并在帖子之间添加一条水平线:

这是否足够简单,我可以将一些代码粘贴到 /admin/customize/themes/1/common/scss/edit 中?
编辑:
对于其他任何人,我使用此处的代码解决了 gravatar 调整大小的问题:
2 个赞
我能够对评论进行样式设置。我的样式设置非常基础,哈哈……但有所改进。
唯一剩下的就是删除 WP-Discourse 导入的评论部分底部的参与者列表。
我无法使用此代码,因为它在使用“self”时会引发错误。是否有解决方法?
ob_start();
?>
<div id="comments" class="comments-area discourse-comments-area">
<div class="comments-title-wrap">
<h2 class="comments-title discourse-comments-title"><?php echo esc_html( self::get_text_options( 'notable-replies-text' ) ); ?></h2>
</div>
<ol class="comment-list">{comments}</ol>
<div class="respond comment-respond">
<h3 id="reply-title" class="comment-reply-title">
<?php echo esc_html( self::get_text_options( 'continue-discussion-text' ) . ' ' ); ?>
<?php self::discourse_topic_link( self::new_tab() ); ?>
</h3>
<p class="more-replies">{more_replies}</p>
</div>
</div>
<?php
$output = ob_get_clean();
我删除了这些行:
<div class="comment-reply-title">
<h4 class="discourse-participants"><?php echo esc_html( self::get_text_options( 'participants-text' ) ); ?></h4>
<p>{participants}</p>
</div>
但是,“self”语法错误我不确定如何解决。特别是这些行:
<?php echo esc_html( self::get_text_options( 'continue-discussion-text' ) . ' ' ); ?>
<?php self::discourse_topic_link( self::new_tab() ); ?>
我没有删除参与者部分。如果您正在考虑这样做,请给它一个机会,就像对待其他 Discourse 功能一样;开发人员已经仔细考虑过它。即使只导入了 15 篇帖子中的 5 篇,它也会显示所有参与者。(可更改的设置)此外,导入的回复排除了 0 级论坛成员的帖子。我觉得这很有帮助。
总之,随着时间的推移,我注意到参与者列表和导入的评论并非总是相同的。在许多情况下,这有助于为博文读者提供更准确的评论活动水平的视图,而无需导入所有帖子或冒着导入第一批注册会员帖子的风险。(我相信这也可以在设置中更改)
2 个赞
angus
(Angus McLeod)
10
我认为 comment_formatter.ERROR: format.missing_post_data 报告得过于频繁了。我将在下一个版本中调整它。感谢您对此事的跟进。除非您遇到明显的问题,否则目前不必担心。
没有关于评论样式的正式指南。还有其他一些主题,例如 这个。WordPress 主题的形状和大小各不相同,最初认为这应由网站管理员自行决定。话虽如此,我认为一些额外的指南可能会有用。
我已将其添加到我的列表中,将添加到 WP Discourse 指南中。我不会在几周内发布,但如果您在此期间在样式方面遇到困难,请告诉我,我会给您一些建议。
2 个赞
system
(system)
关闭
11
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.