Prafulla Kumar Sahu
Forum Replies Created
-
Forum: Plugins
In reply to: [DW Question & Answer] How to override answers.php template ?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.
Forum: Plugins
In reply to: [DW Question & Answer] How to override answers.php template ?removing dwqa_after_single_question_content not working .
remove_action( 'dwqa_after_single_question_content', 'dwqa_load_answers' );
please suggest some idea.
Forum: Plugins
In reply to: [DW Question & Answer] How to override answers.php template ?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') } );
This solved the problem, please let me know if there is a better way.
add_filter( 'dwqa-load-template', function( $template, $name = 'single-question' ){ if ( DWQA_DIR . 'templates/'.$name.'.php' == $template ){ return MY_PLUGIN_DIR . '/dw-question-answer/single-question.php'; } return $template; } );
Forum: Plugins
In reply to: [DW Question & Answer] How to extend filter ? in question archive page urlthank you so much for your reply, already done it. something like
add_filter( 'dwqa_prepare_archive_posts', ' my_answered_by_user_function' ); function my_answered_by_user_function( $query ){ global $wp_query; if ( isset( $_GET['answers_of'] ) ){ $answer_of = !empty( $_GET['answers_of'] ) ? $_GET['answers_of'] : 'all'; unset( $args ); $args = array( 'user' => $answer_of, 'posts_per_page' => -1 ); $questions_answered = My_Class::my_dwqa_refilter_question( $args ); $question_ids = array_unique( $questions_answered['post__in'] ); $query = array( 'post_type' => 'dwqa-question', 'post__in' => $question_ids ); } return $query; }
but thinking to use your .
yes, it can be done using a filter.
add_filter( 'dwqa-shortcode-question-list-content', function( $html ){ return your_html; }
thank you for letting me know that.
Forum: Plugins
In reply to: [DW Question & Answer] How to extend filter ? in question archive page urlI have already posted one or two question, it will great if you will guide me there.
If possible please let me know how I can override content-question.php ? ( if possible using plugin )
Forum: Plugins
In reply to: [DW Question & Answer] How to extend filter ? in question archive page urlThis can be done by applying filter
dwqa_prepare_archive_posts
and modifying the query and another way can be overriding
add_action( 'dwqa_before_questions_list', array( $this, 'prepare_archive_posts' ) );
but the first one is better and I would recommend .
it will be
add_filter( 'dwqa_prepare_archive_posts', function( $query ){ // return modified query $query = array( 'post_type' => 'dwqa-question', 'post__in' => array( 2, 5, 12, 14, 20 ) ) return $query; }
Forum: Plugins
In reply to: [DW Question & Answer] Suggested improvement: answer redirectionHello KTS915, if it is inside loop for answers, you can use also
echo $post->guid . '#' $post->ID
.Forum: Plugins
In reply to: [DW Question & Answer] How to extend filter ? in question archive page urlI think it may be possible with https://localhost/mysite/questions/?user= not+user_name&filter=my-subscribes but how to make it !user_name and how to retrieve his own questions for which he has posted answer that will be a problem . again it seems multiple filters are not allowed . ??
but again it seems
EDIT
https://localhost/mysite/question/?filter=my-subscribes&sort=answers is allowedmaking it like
echo do_shortcode("[dwqa-list-questions number=5, author=" . $post->post_author . " ]");
but it does not work with the arguments I am passing ??
Now I changed it to
function dwqa_refilter_question( $args = null ) { if ( isset( $args ) ){ $posts_per_page = isset( $args['posts_per_page'] ) ? $args['posts_per_page'] : 5; $user = isset( $args['user'] ) ? $args['user'] : get_current_user_id(); } // change 0 to page id you had place other archive page contain shortcode [dwqa-list-questions] //if ( is_page( 0 ) ) { $answer_args = array( 'post_type' => 'dwqa-answer', 'posts_per_page' => $posts_per_page, 'post_status' => 'publish', 'fields' => 'ids', 'no_found_rows' => true, 'update_post_term_cache' => false, 'update_post_meta_cache' => false, 'author' => $user, 'orderby' => 'date' ); // this will return array with 5 answer's ids $answers = get_posts( $answer_args ); $question_lists = array(); foreach( $answers as $answer_id ) { $question_lists[] = get_post_meta( $answer_id, '_question', true ); } $args['post__in'] = $question_lists; //} return $args; }
and please let me know if you think I could have done it in a better way, I would love to learn .