If you are a developer and want to incorporate Quizly in your theme, this section is for you.
You are not limited to adding quizzes to posts via shortcodes alone. The Quizly plugin registers a new post type qy_o_quiz
. Here are some examples of implementing it in your custom template files:
WP_Query
to list all quizzes with thumbnail, title, and description$args = array(
'post_type' => 'qy_o_quiz', // the quiz post type
'post_status' => 'publish',
'posts_per_page' => 6,
'paged' => get_query_var( 'paged' )
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ) {
?>
<div class="quiz-feed">
<?php
while( $loop->have_posts() ) : $loop->the_post();
global $post;
<article>
<a href="<?php the_permalink() ?>" class="entry-image-link">
<?php the_post_thumbnail( 'medium', array( 'class' => 'post-image entry-image') ); ?>
</a>
<header class="entry-header">
<h2 class="entry-title"><a href="<?php the_permalink() ?>" class="entry-title-link"><?php echo get_the_title( $post->ID ); ?></a></h2>
</header>
<div class="entry-content">
<?php esc_html_e( get_post_meta( $post->ID, 'quiz_description', true ) ); ?>
</div>
</article>
<?php endwhile; ?>
</div>
<?php
}
wp_reset_query();
$args = array(
'post_type' => 'post', // regular posts
'post_status' => 'publish',
'posts_per_page' => 6,
'paged' => get_query_var( 'paged' )
);
$loop = new WP_Query( $args );
if( $loop->have_posts() ) {
?>
<div class="post-feed">
<?php
while( $loop->have_posts() ) : $loop->the_post();
global $post;
if ( has_shortcode( $post->post_content, 'quizly') ) { ?>
<article>
<a href="<?php the_permalink() ?>" class="entry-image-link">
<?php the_post_thumbnail( 'medium', array( 'class' => 'post-image entry-image') ); ?>
</a>
<header class="entry-header">
<h2 class="entry-title"><a href="<?php the_permalink() ?>" class="entry-title-link"><?php echo get_the_title( $post->ID ); ?></a></h2>
</header>
<div class="entry-content">
<?php the_excerpt(); ?>
</div>
</article>
<?php } ?>
<?php endwhile; ?>
</div>
<?php
}
wp_reset_query();