Peter Davenport
asked 10 years ago

I have a need to use the template file single-dwqa-question.php to handle the templating of my single questions pages. I have some stuff on my single.php that is appropriate for single blog posts on the site, but not for single question pages. I created single-dwqa-question.php based on the standardized rules for WordPress template hierarchy. However, single questions continue to be displayed using single.php.


I have it working fine with another custom post type, but that CPT uses and underscore instead of a hyphen in the custom post type name. I’m wondering if that has something to do with it. Hiding the extra content via CSS is not the preferred way to handle this and I would rather do it through WP’s templating system.


Can you please advise on this?

Yao Fong Chow
replied 10 years ago

I am facing the same problem.

Both the question list and ask question page style can be controlled from the page setting.
Why not the single question page to the same?

Please advise

3 Answers
answered 10 years ago

Hi Peter, As you can see in the templates folder of DWQA ( ) we have all element templates here, so please create a dwqa-templates folder in your theme folder  then copy any files which you want to edit from <your-plugins-directory>/dw-question-answer/inc/templates/default to <your-theme>/dwqa-templates/ .

replied 7 years ago

Hello, does this work if I want to override /inc/Handle.php?
I placed a file Handle.php in /dwqa-templates but it wasn't recognized.

Is this supposed to work?


replied 7 years ago


Sorry, this won’t work with the DW Q&A core files. However, it will work with the code below.

To override submit_question function.

You can add this function to functions.php at your theme folder.

add_action( ‘init’, ‘dwqa_remove_submit_question_function’ );
function dwqa_remove_submit_question_function() {
$handle_class = dwqa()->handle;
remove_action( ‘wp_loaded’, array( $class_handle, ‘submit_question’ ) );

add_action( ‘wp_loaded’, ‘dwqa_new_submit_question_function’ );
function dwqa_new_submit_question_function() {
// do something

replied 7 years ago

Ok, thanks.

1) Since I am new to PHP and WordPress I can’t tell if this is something that is “heavy”; can it affect user load time of the page?

2) If I want to override your “submit_question” function should I copy and paste it into “dwqa_new_submit_question_function()” and only change the things I want changed?

3) I think you meant “$handle_class” in your call to “remove_action” above, right? (instead of “$class_handle”).

Thank you.

replied 7 years ago


1. The change does not affect page load time.
2. Yes. Just copy the old code in Handle.php then you can change it.
3. Sorry for my mistake. You just replace “$class_handle” to “$handle_class”.

replied 7 years ago


replied 7 years ago

This doesn’t work for me. When adding the submit_question to the functions file, am I supposed to include:

public function submit_question() {

If I do, I get an error. Removing that line, I then get this error:

Using $this when not in object context

replied 7 years ago

hi mate, you can’t add that function to functions.php file, because it’s already exist
The point here is that he want to override the function submit_question()

The guide code there first action is to remove the function submit_question() from DW question answer, and then you need to create a new function to replace the submit_question(). so try to name it different.

in your situation , you remove that line from handle.php file ? it’ll cause bug and the DW Q&A can’t work.

Scott Petrovic
answered 5 years ago

For the PRO version…
I just got it this override working with the paid version of the Q&A Plugin. I had to put the files in a slightly different directory as the files for that are in a different location.
<theme directory>/dwqa-templates/styles/default
I put the “content-single-question.php” in there and it seems to be overriding fine.

Dominic Staff
replied 5 years ago

With the Free version you can copy/paste the file in the to the /dwqa-templates.
About the content-single-question.php file, you can add to the folder.

answered 4 years ago

Iam using twentyseventeen theme and i want to change the content-question.php file. I am overwriting this file in my theme folder. twentyseventeen/dwqa-templates/styles/default/content-question.php but this file is not overridden. Please help me to resolve this issue

Dominic Staff
replied 4 years ago

Please check the style that you selected in the Dashboard > Questions > Settings > General. If you use another style, you need to rename the twentyseventeen/dwqa-templates/styles/default/ folder to the style that you are using.
– Default: twentyseventeen/dwqa-templates/styles/default/
– Flat: twentyseventeen/dwqa-templates/styles/flat/
– Helpdesk: twentyseventeen/dwqa-templates/styles/helpdesk/

Powered by DW Question & Answer Pro