Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Prafulla Kumar Sahu

    (@prafulla)

    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')
    } );
    Thread Starter Prafulla Kumar Sahu

    (@prafulla)

    removing dwqa_after_single_question_content not working .

    remove_action( 'dwqa_after_single_question_content', 'dwqa_load_answers' );

    please suggest some idea.

    Thread Starter Prafulla Kumar Sahu

    (@prafulla)

    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.

    Plugin Author DesignWall

    (@designwall)

    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;
    }
    
    Thread Starter Prafulla Kumar Sahu

    (@prafulla)

    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 .

    Thread Starter Prafulla Kumar Sahu

    (@prafulla)

    your code gives me warning Warning: Missing argument 2 for <function name>

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to override answers.php template ?’ is closed to new replies.