'For showing related question. This widget will only work in question page.') ); } public function widget( $args, $instance ) { $title = apply_filters( 'widget_title', $instance['title'] ); echo $args['before_widget']; if ( ! empty( $title ) ) echo $args['before_title'] . $title . $args['after_title']; if(!class_exists('Tags_For_AnsPress')){ echo 'Tags plugin must be installed for related question. Get Tags for AnsPress'; return; } $tags = get_the_terms(get_question_id(), 'question_tag' ); $tags_in = array(); if($tags) foreach($tags as $t) $tags_in[] = $t->term_id; $question_args=array( 'tax_query' => array( 'taxonomy' => 'question_tag', 'field' => 'id', 'terms' => $tags_in, ), 'showposts' => 10, 'post__not_in' => array(get_question_id()), ); $questions = new Question_Query( $question_args ); include ap_get_theme_location('widget-related_questions.php'); echo $args['after_widget']; wp_reset_postdata(); } public function form( $instance ) { $title = __( 'Related Questions', 'ap' ); if ( isset( $instance[ 'title' ] ) ) $title = $instance[ 'title' ]; ?>