0, 'class' => '', 'target' => '' ), $atts)); $id = intval( $id ); // Find the permalink by finding the post with the meta_key 'quiz_id' of supplied quiz $permalink = ''; $my_query = new WP_Query( array( 'post_type' => 'quiz', 'meta_key' => 'quiz_id', 'meta_value' => $id, 'posts_per_page' => 1, 'post_status' => 'publish' ) ); if ( $my_query->have_posts() ) { while ( $my_query->have_posts() ) { $my_query->the_post(); $permalink = get_permalink(); } } wp_reset_postdata(); // Craft the target attribute if one is passed to shortcode $target_html = ''; if ( ! empty( $target ) ) { $target_html = "target='" . esc_attr( $target ) . "'"; } return "" . esc_html( $content ) . ""; } add_shortcode( 'qsm_link', 'qsm_quiz_link_shortcode' ); /** * Displays a list of most recently created quizes [qsm_recent_quizzes] * @param - attrs - array of shortcode attributes - no_of_quizzes, include_future_quizzes * @param - no_of_quizzes - Number of most recent quizzes to be displayed (default 10) * @param - include_future_quizzes - Whether to display future scheduled quizzes or not - yes/no (default yes) * @since 5.1.0 * @return string - list of quizzes * Shortcode call - [qsm_recent_quizzes no_of_quizzes=5 include_future_quizzes='no' ] */ function qsm_display_recent_quizzes($attrs) { $no_of_quizzes = isset($attrs['no_of_quizzes'])? $attrs['no_of_quizzes']:10; $include_future_quizzes = isset($attrs['include_future_quizzes'])? $attrs['include_future_quizzes']: true; global $wpdb; wp_enqueue_style('quizzes-list', plugins_url('../css/quizzes-list.css', __FILE__)); $quiz_tbl = $wpdb->prefix.'mlw_quizzes'; $query = "SELECT quiz_id, quiz_name, quiz_settings FROM $quiz_tbl WHERE deleted=0 ORDER BY quiz_id DESC"; $quizzes = $wpdb->get_results($query); $result = '