Start the Discussion link at bottom of blog post not working, linking to topic_url

I noticed that the “Start the Discussion” link at the bottom of my Wordpress Blog Post stopped working and is now just linking to “topic_url”.

I am not exactly sure when this stopped working.

I did recently update my Wordpress Theme. I did post a blog post after that update which seem to work just fine and got posted to my Discourse Forum.

Please see below the log:

[2025-02-11 13:53:50] comment.ERROR: sync_comments.response_error {"message":"","discourse_topic_id":"89","wp_post_id":1521,"http_code":""} 

### This file is included in log downloads ###

### Server ###

WordPress - 6.7.2
PHP - 8.0.30
MySQL - 10.11.11

### Active Plugins ###

Avada Builder - 3.11.15
Avada Core - 5.11.15
WP-Discourse - 2.5.6

### WP Discourse Settings (Secrets Excluded) ###

connection-logs - 0
display-subcategories - 1
allow-tags - 1
max-tags - 8
publish-as-unlisted - 0
full-post-content - 1
custom-excerpt-length - 55
add-featured-link - 1
auto-publish - 1
force-publish - 0
force-publish-max-age - 0
publish-failure-notice - 1
auto-track - 1
allowed_post_types - post
exclude_tags - 
hide-discourse-name-field - 1
discourse-username-editable - 0
direct-db-publication-flags - 0
verbose-publication-logs - 0
enable-discourse-comments - 1
comment-type - display-comments
ajax-load - 1
load-comment-css - 1
discourse-new-tab - 1
hide-wordpress-comments - 1
show-existing-comments - 0
max-comments - 8
min-replies - 1
min-score - 0
min-trust-level - 1
bypass-trust-level-score - 50
only-show-moderator-liked - 0
custom-datetime-format - 
cache-html - 0
clear-cached-comment-html - 0
verbose-comment-logs - 0
use-discourse-webhook - 1
webhook-match-old-topics - 0
use-discourse-user-webhook - 0
webhook-match-user-email - 0
verbose-webhook-logs - 1
verbose-sso-logs - 0
enable-sso - 0
auto-create-sso-user - 0
real-name-as-discourse-name - 0
force-avatar-update - 0
redirect-without-login - 0
sso-client-enabled - 1
sso-client-login-form-change - 1
sso-client-sync-by-email - 0
sso-client-sync-logout - 0
logs-enabled - 1

Link to my Wordpress/Discourse: https://www.alphagamer.net/

Hey there @Pieces,

So this specific publication to Discourse worked entirely as expected? And then a subsequent publication produced this unexpected result?

I am not sure what you mean with subsequent publication.

I published a new blog post yesterday. Publishing this post seems to have worked normal and got posted to my Discourse forum as expected. I checked this morning to find out the link below it doesn’t work anymore (I found out by chance). I didn’t do anything special, like updating or any other actions.

I am sure it worked before, I am not sure how long it is not working anymore.

Hope that helps.

I see, thanks for clarifying. When you go into the “edit” view of the post do you see the topic is linked properly in the “Discourse” sidebar?

Hey @angus yes it does show that it is linked and the link seems to work fine.

I see. This suggests to me that there is some other issue with your wordpress instance as the data that sets that URL in the post edit view is the same data that fills the topic_url in the comment template. In other words, the data is there, but it’s not being loaded in the comment template for some reason.

  1. Are you seeing any issues in your PHP logs? If you’re not sure where those are, are you able to ask your hosting provider?
  2. Are you seeing this issue on any other post?
  3. Are you seeing any errors in your browser console?
  4. Could you try disabling ajax loading of comments in the “WP Discourse > Comments” settings and see if that changes anything.

Thanks for responding @angus

  1. I need to have a look tonight, I don’t have access to the PHP logs right at this moment
  2. I am seeing this issue across all posts
  3. I only see a cookie (blocked) related issue in the browser console (I don’t think this is related but happy to take your guidance if it is)
  4. I turned off Ajax and this seems to fix the link, however the link has a lot of additional characters behind the link that is defined in my blogpost on Wordpress (e.g. www.mydomain/post/1 became www.mydomain/post/1?_ahsdkhsdkhkh*lnnjasdfa)

Hi @angus I realized I installed a Child Theme 6 months ago so I can publish a Wordpress post as a onebox on Discourse.

I reactivated the main Theme, issue is still there (if I turn Ajax back on), so I switched back to my Child Theme and turned off Ajax.

Below you see the code of the functions.php of my child theme to make the onebox work.

<?php

function theme_enqueue_styles() {
    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css', [] );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles', 20 );

function avada_lang_setup() {
	$lang = get_stylesheet_directory() . '/languages';
	load_child_theme_textdomain( 'Avada', $lang );
}
add_action( 'after_setup_theme', 'avada_lang_setup' );

//Publish the WordPress post as a onebox on Discourse
function wpdc_custom_publish_format_html( $input, $post_id ) {
	$permalink = get_the_permalink( $post_id );
	ob_start();
	echo $permalink;
	$output = ob_get_clean();

	return $output;
}
add_filter( 'discourse_publish_format_html', 'wpdc_custom_publish_format_html', 10, 2 );

Ok, the issue might be connected to scripting and/or ajax on your Wordpress then. Why did you enable ajax loading? Do you have any concerns about leaving it turned off?

Hi Angus,

I think it was enabled when I installed the plugin, if not I didn’t enable it for a specific reason. I just find it weird that it stopped working without a clear reason (other than a Wordpress or Theme update).

I will keep it turned off for now.

The setting is disabled by default. If there are any javascript issues with your theme or site, it can cause issues with ajax loading.

Yes, I think that’s the solution. You only need to use ajax loading of comments if you have a specific reason to do so.

1 Like

Hey @angus ,

I noticed something today. I got logged out of Wordpress and realized the link is not working if I am logged out (even with Ajax turned off).

When I log into Wordpress and then look at my blog post, the link actually works.

Any thoughts on what might drive this?

Hey @Pieces, that will be something to do with your site, not this plugin. It sounds like something is preventing post custom fields from being loaded in your Wordpress in certain circumstances.

You’ll need to debug that on the Wordpress side of things. If you have a hosting provider or developer, I’d run this issue by them. If you made any changes to the site recently, I’d try reversing the change and see if it fixes the issue.

Hey @angus

What would be the best process to disconnect my Wordpress from Discourse? Is it simply uninstalling (deleting) the plugin in Wordpress (in the plugin section in Wordpress) and removing the API key and Webhook in Discourse?

Am I missing something?

Thanks, Pieces.

All you need to do is remove the plugin from Wordpress, but yes, you can do those other things too.

2 Likes