Or, embed this snippet using GenerateWP WordPress Plugin.

Download

Clone

Testimonials shortcode

Testimonials shortcode to use with Formabase Testimonials plugin

// Add Shortcode
function empform_testimonials_shortcode() {

	// WP_Query arguments
	$args = array(
		'post_type'         => array( 'empform_courses', 'portfolio' ),
		'meta_key'          => '_empform_testimonials',
		'posts_per_page'    => '1',
		'orderby'           => 'rand',
	);
	
	// The Query
	$testimonials_query = new WP_Query( $args );
	
	// The Loop
	if ( $testimonials_query->have_posts() ) {
		while ( $testimonials_query->have_posts() ) {
			$testimonials_query->the_post();
			// show random testimony
			?>
			<?php
			// Testemunhos dos cursos
			
			$course_testimonials = get_post_meta( get_the_ID(), '_empform_testimonials', true );
			?>
			
			<?php if ( $course_testimonials ) : ?>
				
				<?php
				
				foreach ( (array) $course_testimonials as $key => $course_testimony ) {
					
					$testimony = $student_name = '';
					
					if ( isset( $course_testimony['_empform_testimonial_text'] ) ) {
						$testimony = esc_html( $course_testimony['_empform_testimonial_text'] );
					}
					
					if ( isset( $course_testimony['_empform_testimonial_name'] ) ) {
						$student_name = esc_html( $course_testimony['_empform_testimonial_name'] );
					}
					
					$output .= '<div class="ui centered card empform-testimonials">
					<blockquote class="testimonials">
					<p class="testimonials">' . $testimony . '</p>
					<p class="testimony-name">' . $student_name . '</p>
					<p class="testimony-course">'?> <?php the_title( sprintf( '<a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a>' ); ?> <?php '</p>
					</blockquote>
					</div>';
				} ?>
				
			<?php endif; ?>
			<!-- END testemunhos -->
			<?php
		}
	} else {
		// no posts found
	}
	
	// Restore original Post Data
	wp_reset_postdata();
	
	// Return code
	return $output;

}
add_shortcode( 'empform_testimonials', 'empform_testimonials_shortcode' );