Issues with setting up ajax comments

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

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:


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 Likes