• Resolved nmf2024

    (@nmf2024)


    Good morning,

    I would like to add a video to my quiz questions but I cannot find the html code that could allow this manipulation.

    Can you help me ?

    Thanks again !

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

    (@harmonic_design)

    Since you seem to be looking for HTML to edit, I’m going to assume that you are comfortable adding code to your site?

    If so, adding the following to your theme’s functions.php will get you what you need. Just BACKUP OF THE FILE FIRST.

    // Add some content after the featured image
    function hdq_print_question_media($question)
    {
    	if(isset($question["hdq_featured_media"])){
    		if($question["hdq_featured_media"]["value"] != ""){
    			echo apply_filters( 'the_content', $question["hdq_featured_media"]["value"] );
    		}
    	}
    }
    add_action('hdq_after_featured_image', 'hdq_print_question_media');
    
    // Add new custom "Media" field to quiz settings Extra tab
    function hdq_add_featured_media_meta($fields)
    {    
        $tab = "extra";
       
        if (!isset($fields[$tab]) || !is_array($fields[$tab])) {
            $fields[$tab] = array();
        }
    
        // set field settings
        $field = array();
        $field["name"] = "hdq_featured_media"; // should be slug format
        $field["label"] = "Media Embed";
        $field["type"] = "editor";
        $field["tooltip"] = "You can copy/paste a youtube URL to auto embed it, or use the Add Media button to add a local media file";
        array_push($fields[$tab], $field);
        return $fields;
    }
    add_action('hdq_add_question_meta', 'hdq_add_featured_media_meta');

    The above code does two things.

    1. Adds a new editor to quiz settings Extra tab. In this editor, you can do whatever you want: add images, audio, video, etc.
    2. Adds that new content after the featured image. (note: if you are not using a featured image, that’s OK. We are placing this after where it would appear if existed)

    Just note that styling the embeds will be up to you (and is why this is not built into HD Quiz). If your theme already has styles for audio/video embeds, great! If not, you will have to do this yourself.

Viewing 1 replies (of 1 total)
  • The topic ‘Put a video in the quiz question’ is closed to new replies.