Add Commenting Using Standard WordPress Comment Functionality

Thanks for the information here:

https://premium.wpmudev.org/forums/topic/qa-is-missing-comments

It was very useful. But how would I implement this using the standard WordPress commenting functions?

  • Timothy
    • Chief Pigeon

    Hey there.

    As noted in Hakans post:

    https://premium.wpmudev.org/forums/topic/qa-is-missing-comments#post-246389

    You would have to checkout here:

    http://codex.wordpress.org/Function_Reference/comments_template

    You could also download one of our themes, like BP Social for example and take a look at the /bp-social/comments.php file to see how it was done there.

    If this isn’t something you are able to do then you would need to consider hiring a developer for this.

    The QA plugin wasn’t intended to be commented on in such a way, the answers area was the desired functionality.

    However I could see it useful to do comments like StackExchange does on each question and answer.

    I have no idea if Hakan plans to include that in a future version, but I’ll ping him to get his feedback on this.

    Hope this helps.

  • mbreu996
    • WPMU DEV Initiate

    Cool thanks again for the great information Hakan.

    One more thing though…

    qa_after_question_meta

    is very useful but…

    There is nothing to hook to for putting comments after individual answers, only at the end of the answers via

    qa_after_answers

    Is there a way to put an action hook inside

    the_answer_list()

    at this point

    <div class="answer-meta">

  • Hakan
    • The Incredible Smush

    Nope. There is no hook at that point yet, but I can include it for the next version.

    We add action/filter hooks regularly, depending on the user feedbacks, like yours now.

    For the time being you can replace the attached file and safely use your custom functions depending on those hooks, as those hooks will be there with the next update :slight_smile:

    Cheers,

    Hakan

  • djol
    • New Recruit

    Hakan, thank you very much for the extra comment hooks – I was just about to ask this very question when I saw you had already provided a solution. Thanks!

    Like mbreu996, I need comments enabled for both questions and answers as I am finalising an import of a stackexchange database. While I agree that default-themed WP comments are too imposing when appearing among Q&A, unobtrusive, minimalist-themed comments help users to further clarify questions and answers without adding more.

  • djol
    • New Recruit

    Apologies Hakan for reopening this thread – I have not been able to successfully enable comments for both questions and answers.

    I have updated to the patched template-tags.php you provided with the new hooks, then re-edited my functions.php to include:

    function my_qa_comments() {
    echo "<div style='clear:both; height:20px;'></div>";
    comments_template( );
    }
    add_action( 'qa_after_question_meta', 'my_qa_comments' );
    add_action( 'qa_after_answer_meta', 'my_qa_comments' );

    Unfortunately the behaviour I get is that comments appear for the question, but then the same comments repeatedly appear after each answer as well. Comments associated with an answer (both imported and newly submitted) do not appear at all, although I have confirmed that they exist in the database.

    Here’s an example of how this looks on my testing WP install (stock 3.4.1 without any other customisation other than Q&A) where the four comments associated with the question are also repeated after each answer.

    http://www.test.gasexchange.com/questions/how-do-you-deal-with-an-interscalene-nerve-catheter-that-causes-paresthesias-when-you-are-trying-to-pull-it-out/

    Thanks for your help with this – I have obviously set something up wrong, something to do with referencing the answer’s post_id rather than the parent question post_id.

  • Hakan
    • The Incredible Smush

    Hi djol,

    Unfortunately the behaviour I get is that comments appear for the question, but then the same comments repeatedly appear after each answer as well.

    That is the expected result, because you are using the same comment template. However, you should copy your default comment template to a new file and call that file, e.g. comments_template( ‘/answer-comments.php’ ). In that file you should use a query to call the related answers only.

    For reference please see here:

    http://codex.wordpress.org/Function_Reference/comments_template

    Cheers,

    Hakan

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.