Question Answer Plugin

I’ve never used the WP plugin before, but in theory the only thing you’d need to do to get a ‘read only’ version within Wordpress (i.e. you can’t vote, or clicking a ‘vote button’ would send you to the discourse topic itself) would be to customise the WP comment template to support the QA styles.

The key bits would be:

1 - If a topic has qa enabled and the post is not the first post, it’s a ‘comment’ if it’s a reply to a post and it’s an ‘answer’ if its not. This is the version of this logic in the Discourse client customisations in this plugin:

api.addPostClassesCallback((attrs) => {
  if (attrs.topic.qa_enabled && !attrs.firstPost) {
    return attrs.reply_to_post_number ? ["comment"] : ["answer"];
  };
});

2 - Display the property topic.vote_count alongside answers.

The posts should already be in the right order as this plugin changes the sort_order of posts in a topic, which should be respected regardless of what client is consuming the server endpoints (i.e. the Discourse client, or the Wordpress plugin).

5 Likes