Audio file instead of image

[ad_1]

Totally possible! Add the following to your theme’s functions.php file and remember to make a backup of the file first in case you make a mistake.

// create new question option "Featured Media"
function hdq_adriandambrine_add_question_meta($fields)
{
    $field = array();
    $field["type"] = "editor";
    $field["name"] = "hdq_featured_media";
    $field["label"] = "Featured Media";
    array_push($fields["extra"], $field);
    return $fields;
}
add_action("hdq_add_question_meta", "hdq_adriandambrine_add_question_meta");

// print out the content if exists
function hdq_adriandambrine_after_featured_image($question)
{
    if (isset($question["hdq_featured_media"])) {
        echo apply_filters('the_content', $question["hdq_featured_media"]["value"]);
    }
}
add_action("hdq_after_featured_image", "hdq_adriandambrine_after_featured_image");

What the code will do is add a new option/setting to each question under the “extra” tab (same location as where you set the featured image) called “Featured Media”.

In this new section, you can add any content you want and it will appear where the featured image does for each question. Using this you can upload and embed an audio or video player, a youtube video, an additional image – anything!

The only thing to note is that the reason this is not something that is just built into HD Quiz by default is because there is no way for me to be able to style any embedded players you add without ensuring that there is no conflict with your theme. So how an embedded audio player looks will be fully dependent on your theme.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer