I did it this way, please let me know if there is a better way.
remove_action( 'dwqa_after_single_question_content', 'dwqa_load_answers' );
add_action( 'dwqa_after_single_question_content', function( $template ){
include('myplugin/answers.php')
} );
removing dwqa_after_single_question_content not working .
remove_action( 'dwqa_after_single_question_content', 'dwqa_load_answers' );
please suggest some idea.
using dwqa-load-template filter solved the problem, when I tried it first time there was a type 😛
add_filter( 'dwqa-load-template', function( $template, 'answers' ){
if ( DWQA_DIR . 'templates/'.$name.'.php' == $template ){
$template = MY_PLUGIN_DIR . '/dw-question-answer/answers.php';
}
}
** you may need to add a late priority if you are overriding some other template with this filter.
Hi Prafulla Kumar Sahu,
Please try this code below:
add_filter( 'dwqa-load-template', 'dwqa_replace_template' );
function dwqa_replace_template( $template, $name ) {
if ( $name == 'answer.php' ) {
$template = MY_PLUGIN_DIR . '/dw-question-answer/answers.php';
}
return $template;
}
I tried it and get error function was unable to get second argument, I will try it again and let you know.
EDIT
And please check it, I think $name should match “answers” and not “answer.php”, here DWQA_DIR . ‘templates/’.$name.’.php’ you can notice the name is with out file extension .
your code gives me warning Warning: Missing argument 2 for <function name>