Prafulla Kumar Sahu
Forum Replies Created
-
As you guided me I have dwqa_refilter_question() function which I can use to create an archive page this may be another possible way to display all the questions for which thee user has posted answers . I hope any of these either using a filter or this function or if any other better way I will be able to achieve it.
thank you so much for your reply, what I did is created a widget where I want to display the links and there will be a “more..” link to archive page that will display all the questions the user has replayed and I was considering all users as I am adding the widget in single page . so I modified the snippet to make it something like
function dwqa_refilter_question( $args = null, $number_of_post = 5, $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' => $number_of_post, '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; }
no I can provide it the number of post it will return and also the user id for which it will return the questions. now I would like to add my own archive page to display all the questions links the user has answered for which I have already created a separate thread .
It seems it can be also done by doing something like
https://localhost/mysite/questions/?filter=my-answers the same page will be doing the job I want it to display, if any better idea is there please let me know.for now I using a query to get the data, but if possible please let know if there is a better idea. I am doing roughly something like..
SELECT wp_posts.ID as answer_id, wp_posts.guid as answer_uri, wp_posts.post_title as answer_title, wp_postmeta.meta_value as question_id FROM wp_posts INNER JOIN wp_postmeta ON wp_posts.ID = wp_postmeta.post_id WHERE 1=1 AND wp_posts.post_author IN ( $user_id ) AND wp_posts.post_type = 'dwqa-answer' AND wp_posts.post_status IN ( 'publish', 'private' ) ORDER BY wp_posts.post_date DESC
and I believe there must be a better way to do it.
Forum: Plugins
In reply to: [DW Question & Answer] How can I know how many answers a user has provided ?@designwall I hope you are doing well, thank you for your reply, I have another question starting a new thread please reply me there.
Forum: Plugins
In reply to: [DW Question & Answer] How can I know how many answers a user has provided ?echo "Number of question asked" . dwqa_user_question_count(get_current_user_id()); echo "Number of answer provided" . dwqa_user_answer_count(get_current_user_id());