/** * Output single question page * @return void */ public function question_page() { global $questions; $questions = ap_get_question(get_question_id()); if (ap_have_questions()) { /** * Set current question as global post * @since 2.3.3 */ while (ap_questions()) { ap_the_question(); global $post; setup_postdata($post); include ap_get_theme_location('question.php'); } wp_reset_postdata(); } else { include ap_get_theme_location('not-found.php'); } }
<div class="ap-questions-widget clearfix"> <?php if (ap_have_questions()) { /* Start the Loop */ while (ap_questions()) { ap_the_question(); $ans_count = ap_question_get_the_answer_count(); $net_vote = ap_question_get_the_net_vote(); ?> <div class="ap-question-item"> <a class="ap-question-title"href="<?php ap_question_the_permalink(); ?> "><?php the_title(); ?> </a> <span class="ap-ans-count"><?php printf(_n('1 answer', '%d answers', $ans_count, 'ap'), $ans_count); ?> </span> <span class="ap-vote-count"> | <?php printf(_n('1 vote', '%d votes', $net_vote, 'ap'), $net_vote); ?> </span> </div> <?php } } else { _e('No questions found.', 'ap'); }
/** * Output single question page * @return void */ public function question_page() { // Set Header as 404 if question id is not set. if (false === get_question_id()) { $this->set_404(); return; } global $questions; $questions = ap_get_question(get_question_id()); if (ap_have_questions()) { /** * Set current question as global post * @since 2.3.3 */ while (ap_questions()) { ap_the_question(); global $post; setup_postdata($post); } include ap_get_theme_location('question.php'); wp_reset_postdata(); } else { $this->set_404(); } }