<?php if (!defined('ABSPATH')) exit; /* * Crea un shortcode para mostrar los Quizes */ // [quizbook preguntas="" orden=""] function quizbook_shortcode($atts) { $args = array( 'posts_per_page' => $atts['preguntas'], 'orderby' => $atts['orden'], 'post_type' => 'quizes', ); $quizbook = new WP_Query($args); ?> <form name="quizbook_enviar" id="quizbook_enviar"> <div id="quizbook" class="quizbook"> <ul> <?php while ($quizbook->have_posts()) : $quizbook->the_post(); ?> <li> <?php the_title('<h2>', '</h2>'); echo '<p>'.the_content().'</p>'; $opciones = get_post_meta(get_the_ID()); foreach ($opciones as $llave => $opcion) : $resultado = quizbook_filtrar_preguntas($llave); //unset($resultado['qb_correcta']); $numero = explode('_', $llave); if ($resultado === 0) { if ($numero[2] > 0) { ?> <div id="<?php echo get_the_ID() . ":" . $numero[2]; ?>" class=" respuesta "> <?php echo $opcion[0]; ?> </div> <?php } } endforeach; ?> </li> <?php endwhile; wp_reset_postdata() ?> </ul> </div> <!--#quizbook--> <input type="submit" value="Enviar" id="quizbook_btn_submit"> <div id="quizbook_resultado"></div> </form> <!--form--> <?php } add_shortcode('quizbook', 'quizbook_shortcode');
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter