Title: Need Help in coding
Last modified: December 26, 2021

---

# Need Help in coding

 *  Resolved [mubasher99](https://wordpress.org/support/users/mubasher99/)
 * (@mubasher99)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/need-help-in-coding-2/)
 * 1- How can I show total number of quiz questions count. like wp_count_posts()
   
   2- how can I Show the total Quiz Questions posted by authors. I have tried this
   but didn’t get any result. <?php wp_list_authors(‘orderby=post_count&post_type
   =post_type_questionna&order=DESC&number=10&optioncount=1&taxonomy=quiz’); ?>
 * Please Guide

Viewing 4 replies - 1 through 4 (of 4 total)

 *  Plugin Author [Harmonic Design](https://wordpress.org/support/users/harmonic_design/)
 * (@harmonic_design)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/need-help-in-coding-2/#post-15196154)
 * **Total number of questions in a quiz.**
 *     ```
       $quiz_id = 5; // change to the quiz ID
   
       $args = array(
           'post_type'      => 'post_type_questionna',
           'posts_per_page' => -1, // get all posts
           'tax_query' => array(
               'relation' => 'AND',
               array(
                   'taxonomy' => 'quiz',
                   'field'    => 'term_id',
                   'terms'    => $quiz_id
               )
           )
       );
       $q = new WP_Query( $args );
       echo $q->post_count; // prints total questions in that quiz
       ```
   
 * **how can I Show the total Quiz Questions posted by authors. I have tried this
   but didn’t get any result.**
 * Not tested, but something like this should work.
 *     ```
       $author_id = 0; // change to the ID of the author you want to count
   
       $args = array(
           'post_type'      => 'post_type_questionna',
           'posts_per_page' => -1,
           'author' => $author_id
       );
       $q = new WP_Query( $args );
       echo $q->post_count; // prints total questions created by author
       ```
   
 *  Thread Starter [mubasher99](https://wordpress.org/support/users/mubasher99/)
 * (@mubasher99)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/need-help-in-coding-2/#post-15196252)
 * Thank you dear for the help. One last Question:
    What if I want to know “Total
   number of Questions from all the Quizzes”. what would be the code then. Because
   $quiz_id cant work here i think.. Thanks is advance
 *  Plugin Author [Harmonic Design](https://wordpress.org/support/users/harmonic_design/)
 * (@harmonic_design)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/need-help-in-coding-2/#post-15196391)
 * For that, you can just remove the `tax_query` array since it’s not needed. Just
   keep the `post_type` and `posts_per_page` parameters. This will show the total#
   of questions across ALL quizzes.
 *  Thread Starter [mubasher99](https://wordpress.org/support/users/mubasher99/)
 * (@mubasher99)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/need-help-in-coding-2/#post-15196667)
 * Thank you very much for your cooperation dear.. Love your work dear.. <3

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Need Help in coding’ is closed to new replies.

 * ![](https://ps.w.org/hd-quiz/assets/icon-256X256.gif?rev=2936040)
 * [HD Quiz](https://wordpress.org/plugins/hd-quiz/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/hd-quiz/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/hd-quiz/)
 * [Active Topics](https://wordpress.org/support/plugin/hd-quiz/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/hd-quiz/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/hd-quiz/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [mubasher99](https://wordpress.org/support/users/mubasher99/)
 * Last activity: [4 years, 4 months ago](https://wordpress.org/support/topic/need-help-in-coding-2/#post-15196667)
 * Status: resolved