# Issues with setting up ajax comments

**URL:** https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455
**Category:** WordPress
**Created:** [April 16, 2022, 12:26am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455 "2022-04-16T00:26:29Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [April 16, 2022, 12:26am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/1 "2022-04-16T00:26:29Z")

</div>

Scrteenshots:

 ![image](https://global.discourse-cdn.com/meta/original/4X/a/7/9/a79f8028d9ae0e33470723da8ff37a08e32706a3.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/b/8/6/b86760d5d684383cd56f9149940c3a3d9bb66f8d.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/8/3/4/8343d4db76581f12fb2fb1b2dc51b8755694861f.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/d/f/9/df9e47e79ae3807d8e88f3733397185961c0eb38.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/7/e/c/7ecb47d56834a9fee6d5cc614d46e19ee5695c93.png)  
 ![image](https://global.discourse-cdn.com/meta/original/4X/8/a/d/8adf1dff761d41099b8255f36d29e87c0a49efc8.png)

Here’s except of the repeated errors in the logs:

```plaintext
[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"}

```

When I make a new post it works and the topic is created. However, when a comment is made in Discourse it’s not synced to WordPress.

I didn’t change much you can see the setting above. Any ideas about what I’m doing wrong or just missing?

I followed the guides here:

> [@Install and configure the WP Discourse Wordpress plugin for Discourse](https://meta.discourse.org/t/wp-discourse-plugin-installation-and-setup/50752):
>
> To get started with the [WP Discourse](https://github.com/discourse/wp-discourse) Plugin, go through each of these topics in order and watch the videos at the top of the topic. [Install the plugin](https://meta.discourse.org/t/install-the-wp-discourse-plugin/223489/1)[Connect to Discourse](https://meta.discourse.org/t/connect-wp-discourse-to-discourse/223490/1)[Set up Publishing](https://meta.discourse.org/t/wp-discourse-and-publishing-posts-to-discourse/223492/1)[Set up Commenting](https://meta.discourse.org/t/wp-discourse-and-commenting/223493/1)[Set up DiscourseConnect](https://meta.discourse.org/t/wp-discourse-and-discourseconnect/223494/1) The two main plugin features, Publishing and [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true) don’t have to be used together. You can just set up Publishing (and Commenting), and not use [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true), or just set up [DiscourseConnect](https://meta.discourse.org/t/13045?silent=true), or set up both. There’s a short description of each featu…

edit:  
I have this same error, but in the forums, [this was the only search result for](https://meta.discourse.org/t/wp-discourse-comments-are-not-displaying/213467):  
`comment_formatter.ERROR: format.missing_post_data`

Is this a known issue? Or can be solved?

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [April 16, 2022, 8:13am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/2 "2022-04-16T08:13:44Z")

</div>

Hey there,

1. If possible, could you link me to a post on your Wordpress site where you’re seeing the issue?
2. Is there a reason you’re using ajax comments? (you have “Load Comments With Ajax” checked).

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [April 16, 2022, 11:39am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/3 "2022-04-16T11:39:28Z")

</div>

Hi Angus,

1. Yes, sure: [60 Linux Networking commands and scripts | LinuxBlog.io](https://haydenjames.io/linux-networking-commands-scripts/) (that’s the only synced post for now)
2. I checked Ajax only as a last resort after hours of things not working fully. I’ve now _unchecked_ ajax. I’m guessing without webhooks, the interval for syncing took a while.

It seems to work now, but the format is a bit inelegant. I’m guessing I have to figure out CSS?

Also, is there a way to show the “join the discussion” type links to our Discourse forum homepage for older WP blog posts? - In other words, if there are no comments on a post, or if the post has not been previously synced to Discourse, then the plugin will add a general link to my Discourse forum homepage instead of leaving it blank.

Thanks much for helping.

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [April 18, 2022, 6:24am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/4 "2022-04-18T06:24:48Z")

</div>

> [@haydenjames](#):
>
> It seems to work now, but the format is a bit inelegant. I’m guessing I have to figure out CSS?

Yes, how it displays will depend on your theme. There is minimal styling in the plugin itself.

> [@haydenjames](#):
>
> Also, is there a way to show the “join the discussion” type links to our Discourse forum homepage for older WP blog posts? - In other words, if there are no comments on a post, or if the post has not been previously synced to Discourse, then the plugin will add a general link to my Discourse forum homepage instead of leaving it blank.

The join the discussion link will not appear on topics that are not linked. You can add something like this yourself, separately from the plugin though by using the comments\_template filter in your theme’s functions.php file. I haven’t tested this code, but something like this will work:

```plaintext

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" );

```

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [May 2, 2022, 9:28am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/5 "2022-05-02T09:28:10Z")

</div>

4 posts were split to a new topic: [Comment formatter errors in logs](https://meta.discourse.org/t/comment-formatter-errors-in-logs/225856)

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [April 19, 2022, 5:17pm UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/7 "2022-04-19T17:17:33Z")

</div>

Thanks again for the additional help and guidance!

I’ve been reading and searching for CSS to paste that would improve the layout even just a little.

However, as I’m not familiar with CSS/styling (other than pasting _existing_ CSS), I would like to make very basic modifications to the styling of the imported comments. Namely, to use smaller avatar images beside the discourse usernames in the comments and add a horizontal line between posts:  
 ![image](https://global.discourse-cdn.com/meta/optimized/4X/b/6/f/b6fe7843f611a8984de3b6bca45ec16b2c4bb531_2_690x51.png)

Is that something simple enough that I can paste some code into **/admin/customize/themes/1/common/scss/edit**?

**Edit:**  
For anyone else, I was able to solve gravatar resize using the code here:

> [@Customize the structure of WP Discourse templates](https://meta.discourse.org/t/wp-discourse-template-customization/50754/42):
>
> Edit: I got it working and pasted the correct code below for anyone else with same challenge: @angus After some reading I found the location to override the size of gravatar on [WP Discourse](https://github.com/discourse/wp-discourse) comments. in my functions.php I added this (but get error/see below): // Customizes the comment\_html template. function my\_wpd\_comment\_html( $input ) { ob\_start(); ?\> \<li class="comment \<?php echo $even ? 'even' : 'odd'; ?\> depth-1"\> \<article class="comment-body"\> \<footer class="comment-meta…

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [April 20, 2022, 12:53am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/8 "2022-04-20T00:53:50Z")

</div>

I was able to style comments. Very basic was my styling lol… but an improvement.

The only thing left to do is to remove the list of participants at the bottom of WP- Discourse imported comment section.

I can’t use this code because it throws an error due to using “self”. Is they are a workaround?

```plaintext
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();

```

I removed these lines:

```plaintext
<div class="comment-reply-title">
<h4 class="discourse-participants"><?php echo esc_html( self::get_text_options( 'participants-text' ) ); ?></h4>
<p>{participants}</p>
</div>

```

However, the “self” syntax error I’m not sure how to solve. Especially these lines:

```plaintext
<?php echo esc_html( self::get_text_options( 'continue-discussion-text' ) . ' ' ); ?>
<?php self::discourse_topic_link( self::new_tab() ); ?>

```

---

<div class="post-metadata">

### Author: ![haydenjames](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/haydenjames/32/255678_2.png) [@haydenjames](https://meta.discourse.org/u/haydenjames)
#### Post date: [April 27, 2022, 11:46am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/9 "2022-04-27T11:46:48Z")

</div>

> [@](#):
>
> The only thing left to do is to remove the list of participants

I didn’t remove the participants’ section. If you are thinking about doing so, give it a chance, as with other Discourse features; the Devs have put some thought into it. It shows all participants even after only 5 of 15 posts are imported. (changeable setting) Also, the imported responses exclude posts by level 0 forum members. Which I find helpful.

In short, over time, I’ve noticed that it’s not all the time the participants’ list and the imported comments will be identical. In many cases, it helps to provide the blog reader a more accurate view of the level of comment _activity_ without having to import every single post or risk importing posts from the first sign-up members. (which I believe can be changed in settings as well)

---

<div class="post-metadata">

### Author: ![angus](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/angus/32/341715_2.png) [@angus](https://meta.discourse.org/u/angus)
#### Post date: [April 18, 2022, 3:47pm UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/10 "2022-04-18T15:47:38Z")

</div>

I think the `comment_formatter.ERROR: format.missing_post_data` is being over eager in its reporting. I’ll tweak that for the next release. Thanks for following up about it. I wouldn’t worry about it for now, unless you’re experiencing a visible issue.

> [@Comment formatter errors in logs](https://meta.discourse.org/t/comment-formatter-errors-in-logs/225856/1):
>
> Are there any other threads besides this one on customizing the Discouse comments imported to WordPress?

There isn’t a formal guide on comment styling. There are a few other topics, e.g. [this one](https://meta.discourse.org/t/discourse-comment-section-formatting-on-wordpress-divi-theme/169956/4). Wordpress themes come in so many shapes and sizes that it was initially thought to leave this up to the site admin. That said, I think some additional guides may be useful.

I’ve put it on my list to add to the [WP Discourse](https://github.com/discourse/wp-discourse) guides. I won’t publish that for a few weeks, but if you get stuck with styling in the meantime let me know and I’ll give you some pointers.

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [June 1, 2022, 9:28am UTC](https://meta.discourse.org/t/issues-with-setting-up-ajax-comments/224455/11 "2022-06-01T09:28:23Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
