From your question, it seems you’re trying to override the single template of a custom post type. If so, the filter you want to use is single_template
and not page_template
:
function single_page_template($single_template) {
global $post;
if ($post->post_type == 'dwqa-question') {
$single_template = get_stylesheet_directory() . '/page-question.php';
}
return $single_template;
}
add_filter( 'single_template', 'single_page_template' );
I once had this issue and it was driving me crazy, until I found the filter on the WordPress Codex: https://codex.wordpress.org/Plugin_API/Filter_Reference/single_template