function hdq_add_shortcode_random_Tamas($atts) { // Attributes extract( shortcode_atts( array( 'quizzes' => null, ), $atts ) ); $quiz = 0; if ($quizzes === null) { // get random quiz. Not included for this demo } else { // get random id from attr $quizzes = explode(",", $quizzes); $quiz = $quizzes[array_rand($quizzes, 1)]; } // Code ob_start(); include plugin_dir_path(__DIR__). '../plugins/hd-quiz/includes/template.php'; return ob_get_clean(); } add_shortcode('HDQRandom', 'hdq_add_shortcode_random_Tamas');