• Resolved KTS915

    (@kts915)


    For anyone wanting to put quiz questions in a specific order, the developer recommends using the plugin Intuitive Custom Post Order. This does indeed work very well.

    If, however, you would like to have the questions display in random order, just add the following code to your (child) theme’s functions.php file:

    // randomize order of quiz questions
    function order_quiz_questions( $query ) {
        if ( $query->get( 'post_type', 'post_type_questionna' ) ) {
            $query->set( 'orderby', 'rand' );
        }
    }
    add_action( 'pre_get_posts', 'order_quiz_questions' );

    https://ww.wp.xz.cn/plugins/hd-quiz/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Harmonic Design

    (@harmonic_design)

    I really like the way you think KTS915! You seem to be filling in the gaps of my thinking.

    The next major release of HD Quiz will contain an option on each question to randomize the order of it’s answers, but I never even considered that people may want to randomize the order of the questions themselves.

    Although your function would certainly work, I’d have to recommend against most people using it simply because it would be a global option – meaning it would affect every quiz.

    I’ll add a quiz option to randomize the order of questions in my next release so that you can control it on a per quiz basis. Thanks for the idea!

    all the best,
    ~Harmonic Design

    Thread Starter KTS915

    (@kts915)

    Wow, thanks — even better!

    Since you seem to be going along much faster than I expected, I’ll ask about two other things that I was going to leave till a bit later. But I’ll open another thread for them.

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

The topic ‘Randomize questions’ is closed to new replies.