Joep_Kannegieter reports that the WP-Discourse plugin isn’t displaying the link back to Discourse on WordPress posts, despite correct settings and synced comments. He encounters PHP notices related to null array offsets in discourse-comment-formatter.php, tied to URL construction. Initially, manually calling get_post_meta(..., 'discourse_permalink', true) returned nothing, but later worked — yet the link still didn’t render. He’s using Bricks Builder, which doesn’t auto-replace WordPress comments with Discourse comments, forcing him to manually insert PHP code. angus suggests this is likely a template builder load priority issue. Joep confirms the plugin works with the Twenty Twenty theme but fails with Bricks, even when calling get_discourse_comments() manually — which throws an error due to missing required parameters. angus explains that the upcoming 2.4.6 plugin release will update get_discourse_comments() to accept 4 parameters, allowing better control over display type and caching. Joep finds a workaround using <?php comments_template(); ?> to bypass Bricks’ comments element and use WordPress core, which successfully renders Discourse comments. He plans to consult the Bricks community for deeper compatibility fixes. angus provides the correct function signature for the updated utility: get_discourse_comments($post->ID, true, true, 'display-comments').
I have an issue where on the WP side there is no link available to the Discourse forum. Just some answers on forum topics i found about this:
All ’ Text Content’ fields are filled in in the WP admin → Plugin section.
The sync runs; i can see the comments on both sides.
The URL string is available in the _postmeta db table
The comments section shows me Notices:
**Notice**: Trying to access array offset on value of type null in **/home/u48255p44743/domains/fxweb.snowfreakz.nl/public_html/wp-content/plugins/wp-discourse/lib/discourse-comment-formatter.php** on line **90**
**Notice**: Trying to access array offset on value of type null in **/home/u48255p44743/domains/fxweb.snowfreakz.nl/public_html/wp-content/plugins/wp-discourse/lib/discourse-comment-formatter.php** on line **106**
**Notice**: Trying to access array offset on value of type null in **/home/u48255p44743/domains/fxweb.snowfreakz.nl/public_html/wp-content/plugins/wp-discourse/lib/discourse-comment-formatter.php** on line **127**
**Notice**: Trying to access array offset on value of type null in **/home/u48255p44743/domains/fxweb.snowfreakz.nl/public_html/wp-content/plugins/wp-discourse/lib/discourse-comment-formatter.php** on line **127**
**Notice**: Trying to access array offset on value of type null in **/home/u48255p44743/domains/fxweb.snowfreakz.nl/public_html/wp-content/plugins/wp-discourse/lib/discourse-comment-formatter.php** on line **148**
**Notice**: Trying to access array offset on value of type null in **/home/u48255p44743/domains/fxweb.snowfreakz.nl/public_html/wp-content/plugins/wp-discourse/lib/discourse-comment-formatter.php** on line **148**
Which are all related to the $URL in the file. I am calling the comments with:
<?php
global $post;
use WPDiscourse\Utilities\Utilities as DiscourseUtilities;
$discourse_comments = DiscourseUtilities::get_discourse_comments($post->ID);
echo $discourse_comments;
?>
Thnx for reaching out … it’s a “fresh” Wordpress installation running Bricks template builder and just installed WPdiscourse for the connection. Besides mod_headers server caching there are no other aggressive plugins altering any scripts.
Just added the direct PHP line again and … magically the URL is there. No idea what i did different.
<?php
global $post;
use WPDiscourse\Utilities\Utilities as DiscourseUtilities;
$discourse_comments = DiscourseUtilities::get_discourse_comments($post->ID);
echo $discourse_comments;
echo get_post_meta( $post->ID, 'discourse_permalink', true );
?>
But i still have the Notices which relate to code lines where the URL should be constructed and the link after " Continue the discussion at" is not showing.
When I include the “main” wordpress comments (which is a bricks template element) it shows the “normal WP comment form” which is not replaced by the Discourse reviews plugin. See the above URL; i changed the lay-out adding the WP comments below the Blog.
There will be various updates to the get_discourse_comments utility function in the next release (2.4.6), which is currently being prepared for release. The updated utility method signature will look like this
/**
* Get the Discourse comment HTML so that it can be displayed without loading the comments template.
*
* @param int $post_id The post ID to display the comments for.
* @param bool $perform_sync Determines whether a comment sync is maybe performed when loading comments.
* @param bool $force_sync Determines whether comment sync cache is bypassed when loading comments.
* @param string $comment_type Type of comment display.
*
* @return string
*/
public static function get_discourse_comments( $post_id, $perform_sync = true, $force_sync = false, $comment_type ) {
@Joep_Kannegieter This will have a few upshots for your case (and a few other cases):
The comment display will work
You’ll control the comment display type (i.e. all comments or comment link) programmatically
Coming back here; basically “i get it working” although not with the Bricks Builder template.
When i switch to twentytwenty theme the Discourse integration shows below the blog post, replacing the Comments field
When using Bricks Builder there is an element “Comments” which loads the WP comments; which is not replaced by the plugin. Neither programmatically called with:
Error: Too few arguments to function WPDiscourse\Utilities\Utilities::get_discourse_comments(), 1 passed in /home/u43655p432443/domains/domain.nl/public_html/wp-content/themes/bricks/includes/elements/code.php(159) : eval()'d code on line 4 and exactly 4 expected
So its Bricks related. Gonna ask the Bricks commmunity as well.
This error is telling you that your use of the utility function get_discourse_comments needs updating. Here’s an example of how you could use it.
global $post;
use WPDiscourse\Utilities\Utilities as DiscourseUtilities;
$discourse_comments = DiscourseUtilities::get_discourse_comments($post->ID, true, true, 'display-comments');
echo $discourse_comments;