Migrating from wp-discourse-embed to WP Discourse – old posts not showing up

For nearly five years, my blog ran with @techAPJ ’s wp-discourse-embed. Here’s an example of a post

https://www.alittlebitofspice.com/soya-chunks-masala-dry-recipe and corresponding forum post: Soya Chunks Masala Dry - blog - comments

I was able to migrate and set up @angus’s WP Discourse:

But now, the old forum posts don’t appear as comments on blog posts. The above blog post is an example.

I am guessing there needs to be some mapping.

How can I integrate this?

Here’s how my log looks like

And the latest one:

[2024-04-03 01:42:27] webhook_topic.ERROR: update_topic_content.webhook_verification_error [“message”,“Discourse Webhook Request Error: signatures did not match.”]

Raw Logs here.

1 Like

Hello,

About:

This error means the Webhook Secret Key option value in WP-Discourse doesn’t match the password defined in your Discourse webhook. Can you check it?

@simon will correct me if I’m wrong, but yes, a WP post needs to be synced to a Discourse topic. For existing topics, you should have the option to link to an existing Discourse topic:
image.
Once synced, the comments should be retrieved.

I’m not sure if there is a better way; hopefully, some can provide better insights.

4 Likes

You are correct about both issues.

@Jane_Jojo, try linking an existing Discourse topic to its corresponding WordPress post using the method that @Arkshine demonstrated. Note that the user interface is slightly different depending on whether you’re using the Classic WordPress editor or the new Block editor.

If linking Discourse topic to a WordPress post works, the next thing to figure out will be how to link all of your existing topics and posts. How many old posts do you have? If it’s too many posts to link to Discourse manually, there might be a way to automate the process.

2 Likes

Thank you.

So I did this.

and I get a 200 when I do a ping. So that’s clear.

Then I do this:


But the post does not reflect it

Am I missing anything else? The logs don’t seem to have any update.

Update:
When I do ping from discourse webhook

I get this on the log side

[2024-04-03 21:38:14] webhook_topic.ERROR: update_topic_content.response_body_error

Is your WordPress use a cache plugin?

You might need to enable this setting:

Also, if not already, enabling debugging on comments could help:

The error message you are seeing will be generated if you “ping” the webhook. On the WordPress end, the code is expecting there to be a post object in the webhook that’s sent from Discourse. The post will not be in the payload if you just click the “ping” button. Try leaving a comment on a Discourse topic that’s linked to Discourse and see if that still gives you an error.

For the issue of getting Discourse comments to appear on your WordPress site:

  • make sure that comments are enabled on WordPress for the posts you are publishing to Discourse
  • make sure that the “Enable Discourse Comments” option is enabled:

If you have not previously had comments enabled on your WordPress site, you may not want to enable them now for posts that are not yet connected to Discourse. To avoid having the WordPress comment form displayed for those posts, you can enable comments site-wide, then select the “Remove WordPress Comments Template” setting from the WP Discourse Commenting Options page:

Let us know if you are still running into problems.

1 Like

Enabled both. No luck.


Page refreshed and logs arent showing anything

When I do a view source of the page, I see a bunch of discourse references in the html. So its trying something…

This is how my comments section settings have been for a very long time.

Can you check to make sure that comments are enabled for a post that you have linked to Discourse? Sometimes the “Discussion” option isn’t shown on the edit page. You might need to select it from the “Screen Options” menu to see it:

Yes, this was enabled :frowning:

Hmm, I’m not seeing anything on the page that indicates the comment template is being loaded. The reference to discourse-embed-js in your screenshot is not from the WP Discourse plugin. I think it’s related to the script that was loaded by the wp-discourse-embed plugin. It’s actually triggering an error on your site:

Failed to load resource: the server responded with a status of 404 () discourse-embed.js

There’s also a <div id="discourse-comments"></div> on the page that’s from the wp-discourse-embed plugin, not the WP Discourse plugin.

I wouldn’t enable the WP Discourse “Load Comments With Ajax” setting until you confirm that there’s an issue with cached comments on the site. Even if that was the case, it should be able to get the comment template to display.

Are there any plugins installed on your site related to comments? I’m wondering if a plugin, or the site’s theme is preventing the WordPress comment template from being loaded. The WP Discourse plugin depends on that template being loaded. There are a few workaround for that, but they’re all fairly technical.

I’m sure it will be possible to get things sorted out :slight_smile:

1 Like

I was going through my theme code history and realized some time back that I had changed all the WP comments code to discourse comments.

I suspect the legacy one is needed, right?

I’m going from memory here, but I don’t think the edited comments.php file is the cause of the issue. What should be happening is that instead of your theme’s comments.php file being loaded, the WP Discourse plugin should be loading its own comments section when this function is called from your theme: comments_template().

Have a look at your theme’s single.php file, or whatever file is used for displaying a post that you have linked to Discourse. See if the file contains a call to comments_template(). It will look something like this:

if ( comments_open() || get_comments_number() ) :
	comments_template();
endif;

It’s the call to coments_template() that should trigger the WP Discourse comments to load.

I could be wrong about this. I can have a closer look if that doesn’t help to sort things out.

I managed to resolve the issue. Comments were disabled at the theme level. Enabling it fixed it.

Thank you for the detailed responses.

1 Like