ecHo
asked 6 years ago

Hi, i found a little error. When question select “closed“; comment don’t showing but answer is no problem only comment deleting.. what i need to fix? any suggestn?

2 Answers
DominicStaff
answered 6 years ago

I have checked on our demo and still work fine, please send me username & password of your site for further checking.

dumann78
replied 6 years ago

Thank for your support, now looking everythings ok..

Yun X
answered 6 years ago

I have the same issue, and I do think it is a bug.
In line 124 of content-answer.php file:

<?php if ( ! dwqa_is_closed( $question_id ) ) { ?>
<div class="dwqa-comments">
    <?php comments_template(); ?>
</div>
<?php } ?>

So if the question is closed, the comments DIV (with “dwqa-comments” class) will not get shown at all, so the existing comments are invisible, with the form for adding new comment together.
Simply comment out the “if” block can make those comments always visible, however the form to add new comment will still get displayed even when the question is closed. I finally figure it out by modifying two files: “content-answer.php” and “comments.php”. I copied them from “dw-question-answer/inc/templates/default” to the “MyTheme/dwqa-templates/” directory, and then modify the copies.
I commented out the two PHP blocks above and below the “dwqa-comments” DIV, so it can always be visible, then I added these on line 31 in comments.php:

$question_id = get_post_meta( get_the_ID(), '_question', true );
if (empty($question_id)) {
    $question_id = get_the_ID();    
}

The reason to do so is that, we need to get the question’s post id, when the current post is an answer. Otherwise the later call of dwqa_is_closed() function will not work correctly.
Also I modify line 32 a little bit, to use $question_id instead of the answer’s post id:

<?php if ( ! dwqa_is_closed( $question_id ) && dwqa_current_user_can( 'post_comment' ) ) { ?>

I hope these can be useful for someone that meets the same issue. It would be great if DesignWall can fix it in official release, thanks in advance.

Dominic Staff
replied 6 years ago

Awesome ! Thank for your solution, I appreciate it.

Powered by DW Question & Answer Pro