Easy Testimonials Shortcodes

Below, you’ll find a detailed guide on how to add the Easy Testimonials Shortcodes to your WordPress website, including their parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the Easy Testimonials Plugin shortcodes not to show or not to work correctly.

Before starting, here is an overview of the Easy Testimonials Plugin and the shortcodes it provides:

Plugin Icon
Easy Testimonials

"Easy Testimonials is a powerful WordPress plugin that effortlessly allows you to add, manage, and display testimonials on your website. Enhance credibility and trust with this user-friendly tool."

★★★✩✩ (88) Active Installs: 20000+ Tested with: 6.1.4 PHP Version: 5.3
Included Shortcodes:
  • [single_testimonial]
  • [random_testimonial]
  • [easy_testimonials]
  • [testimonials_cycle]
  • [easy_t_testimonials_grid]
  • [testimonials_count]
  • [easy_t_search_testimonials]

Easy Testimonials [single_testimonial] Shortcode

The Easy Testimonials plugin shortcode is designed to output a single testimonial. It accepts various attributes including ‘testimonials_link’, ‘show_title’, and ‘body_class’. It allows customization of the testimonial display, including the option to reveal full content, limit words, show ratings, and more.

Shortcode: [single_testimonial]

Parameters

Here is a list of all possible single_testimonial_shortcode shortcode parameters and attributes:

  • testimonials_link – link to the page with all testimonials
  • show_title – controls whether to show the title or not
  • body_class – CSS class for the testimonial body
  • author_class – CSS class for the testimonial author
  • id – unique identifier of the testimonial
  • use_excerpt – determines if only a short excerpt should be displayed
  • reveal_full_content – shows the full testimonial when clicked
  • show_thumbs – controls whether to show thumbnail images or not
  • short_version – displays a shorter version of the testimonial
  • word_limit – sets a limit on the number of words displayed
  • show_rating – controls whether to show the rating or not
  • theme – sets the style theme for the testimonial
  • show_position – controls whether to show the author’s position or not
  • show_date – controls whether to show the testimonial date or not
  • show_other – controls whether to show other testimonials or not
  • width – sets the width of the testimonial
  • hide_view_more – hides the ‘view more’ button if set
  • output_schema_markup – controls whether to output schema markup or not

Examples and Usage

Basic example – Display a single testimonial using its unique ID.

[single_testimonial id=1 /]

Advanced examples

Display a single testimonial with a custom author class and body class, and without the title.

[single_testimonial id=1 author_class="custom_author" body_class="custom_body" show_title=0 /]

Display a single testimonial with a custom theme, showing the date and position, but without showing other details.

[single_testimonial id=1 theme="dark_grey-classic_style" show_date=true show_position=true show_other=false /]

Display a single testimonial with a custom width, hiding the ‘view more’ link, and without outputting schema markup.

[single_testimonial id=1 width="300px" hide_view_more=1 output_schema_markup=false /]

Display a single testimonial with a word limit, showing ratings as stars, and revealing full content.

[single_testimonial id=1 word_limit=50 show_rating="stars" reveal_full_content=true /]

PHP Function Code

In case you have difficulties debugging what causing issues with [single_testimonial_shortcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( $this->shortcodes['single_testimonial_shortcode'], array($this, 'outputSingleTestimonial') );

Shortcode PHP function:

function outputSingleTestimonial($atts)
	{
		//load shortcode attributes into an array
		$atts = shortcode_atts( array(
			'testimonials_link' => get_option('testimonials_link'),
			'show_title' => 0,
			'body_class' => 'testimonial_body',
			'author_class' => 'testimonial_author',
			'id' => '',
			'use_excerpt' => false,
			'reveal_full_content' => false,
			'show_thumbs' => get_option('testimonials_image', true),
			'short_version' => false,
			'word_limit' => false,
			'show_rating' => 'stars',
			'theme' => get_option('testimonials_style', 'light_grey-classic_style'),
			'show_position' => true,
			'show_date' => true,
			'show_other' => true,
			'width' => false,
			'hide_view_more' => 0,
			'output_schema_markup' => get_option('easy_t_output_schema_markup', true)
		), $atts );
		
		if ( $atts['reveal_full_content'] ) {
			$atts['use_excerpt'] = true;
		}
						
		//load testimonials
		$testimonial = get_post( $atts['id'], OBJECT );
		
		//prep content for return
		$content = "";
		
		//return nothing if a bad ID is passed (no testimonial found)
		if(!empty($testimonial)){
			//create a new testimonial object by passing in the current testimonial			
			$data = array(
				'testimonial' => $testimonial,
				'atts' => $atts
			);
			
			$testimonial = new GP_Testimonial($data, $this->config);
			
			ob_start();
			
			//output the testimonials HTML
			$testimonial->render();
			$content = ob_get_contents();
			
			ob_end_clean();
		}
		
		return apply_filters( 'easy_t_single_testimonial_html', $content);
	}

Code file location:

easy-testimonials/easy-testimonials/easy-testimonials.php

Easy Testimonials [random_testimonial] Shortcode

The Easy Testimonials plugin shortcode generates a random testimonial. It’s customizable, allowing you to set the count, word limit, and style among other parameters. This shortcode fetches testimonials and displays them randomly. It also supports customization such as the number of testimonials, category, and display settings. The output can be filtered for further modifications.

Shortcode: [random_testimonial]

Parameters

Here is a list of all possible random_testimonial_shortcode shortcode parameters and attributes:

  • testimonials_link – URL to the page with all testimonials
  • count – number of testimonials to display
  • word_limit – limits the number of words in testimonials
  • body_class – CSS class for the testimonial body
  • author_class – CSS class for the testimonial author
  • show_title – whether to display the testimonial title
  • short_version – display a shorter version of the testimonial
  • use_excerpt – use the testimonial excerpt instead of full text
  • reveal_full_content – show the full testimonial on click
  • category – display testimonials from a specific category
  • show_thumbs – whether to display the testimonial author’s image
  • show_rating – display the testimonial rating as stars
  • theme – set the style theme for the testimonials
  • show_date – whether to display the testimonial date
  • show_other – display other data from the testimonial
  • width – set a specific width for the testimonial
  • hide_view_more – hide the “View More” button
  • output_schema_markup – whether to output schema markup for SEO

Examples and Usage

Basic example – This example demonstrates how to use the shortcode to output a random testimonial with the default parameters.

[random_testimonial_shortcode /]

Advanced examples

Displaying a random testimonial from a specific category. This example shows how to use the shortcode with the ‘category’ parameter to output a random testimonial from a specific category.

[random_testimonial_shortcode category='customer-reviews' /]

Limiting the word count of a random testimonial. This example shows how to use the shortcode with the ‘word_limit’ parameter to limit the word count of the outputted testimonial.

[random_testimonial_shortcode word_limit=50 /]

Displaying a random testimonial without the title. This example shows how to use the shortcode with the ‘show_title’ parameter set to 0 to hide the title of the testimonial.

[random_testimonial_shortcode show_title=0 /]

Displaying multiple random testimonials. This example shows how to use the shortcode with the ‘count’ parameter to output multiple random testimonials.

[random_testimonial_shortcode count=3 /]

Displaying a random testimonial with a custom style. This example shows how to use the shortcode with the ‘theme’ parameter to apply a custom style to the testimonial.

[random_testimonial_shortcode theme='dark_grey-classic_style' /]

Displaying a random testimonial without the date. This example shows how to use the shortcode with the ‘show_date’ parameter set to false to hide the date of the testimonial.

[random_testimonial_shortcode show_date=false /]

PHP Function Code

In case you have difficulties debugging what causing issues with [random_testimonial_shortcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( $this->shortcodes['random_testimonial_shortcode'], array($this, 'outputRandomTestimonial') );

Shortcode PHP function:

function outputRandomTestimonial($atts){
		//load shortcode attributes into an array
		$atts = shortcode_atts( array(
			'testimonials_link' => get_option('testimonials_link'),
			'count' => 1,
			'word_limit' => false,
			'body_class' => 'testimonial_body',
			'author_class' => 'testimonial_author',
			'show_title' => 0,
			'short_version' => false,
			'use_excerpt' => false,
			'reveal_full_content' => false,
			'category' => '',
			'show_thumbs' => get_option('testimonials_image', true),
			'show_rating' => 'stars',
			'theme' => get_option('testimonials_style', 'light_grey-classic_style'),
			'show_date' => true,
			'show_other' => true,
			'width' => false,
			'hide_view_more' => 0,
			'output_schema_markup' => get_option('easy_t_output_schema_markup', true)
		), $atts );
		
		ob_start();
		
		
		//load testimonials
		$testimonials_loop = $this->get_testimonials_loop( array( 'post_type' => 'testimonial','posts_per_page' => $atts['count'], 'easy-testimonial-category' => $atts['category'], 'orderby' => 'rand') );
		
		//
		
		$testimonials = $testimonials_loop->get_posts();
		
		//loop through and output testimonials
		foreach($testimonials as $testimonial){
			$data = array(
				'testimonial' => $testimonial,
				'atts' => $atts
			);
			
			$testimonial = new GP_Testimonial($data, $this->config);
			
			//output the testimonials HTML
			$testimonial->render();
		}
		
		wp_reset_postdata();
		
		//capture the content from the output buffer`
		$content = ob_get_contents();
		ob_end_clean();
		
		//return the content, with the filter applied
		return apply_filters('easy_t_random_testimonials_html', $content);
	}

Code file location:

easy-testimonials/easy-testimonials/easy-testimonials.php

Easy Testimonials [easy_testimonials] Shortcode

The Easy Testimonials shortcode is a powerful tool that allows you to display testimonials on your website. The shortcode accepts various parameters, such as ‘testimonials_link’, ‘show_title’, ‘count’, ‘body_class’, ‘author_class’, and more. It enables you to control the number of testimonials displayed, their order, and appearance. It also supports pagination and category filtering, making it versatile for different website layouts and styles. The shortcode ensures that your testimonials are presented in an organized and attractive manner.

Shortcode: [easy_testimonials]

Parameters

Here is a list of all possible easy_testimonials shortcode parameters and attributes:

  • testimonials_link – Defines link for the testimonials page.
  • show_title – Show or hide the title of the testimonial.
  • count – Number of testimonials to display.
  • body_class – CSS class for the testimonial body.
  • author_class – CSS class for the testimonial author.
  • id – Testimonial’s unique identifier.
  • use_excerpt – Show only the excerpt of the testimonial.
  • reveal_full_content – Reveal the full content of the testimonial.
  • category – Filter testimonials by category.
  • show_thumbs – Display or hide testimonial thumbnails.
  • short_version – Display a shorter version of the testimonial.
  • orderby – Order testimonials by a specific parameter.
  • order – Order testimonials in ascending or descending order.
  • show_rating – Show or hide the rating of the testimonial.
  • paginate – Enable or disable pagination for testimonials.
  • testimonials_per_page – Number of testimonials to show per page.
  • theme – Theme style for testimonials.
  • show_date – Show or hide the date of the testimonial.
  • show_other – Show or hide other details of the testimonial.
  • width – Set the width of the testimonial.
  • hide_view_more – Hide or show the view more button.
  • output_schema_markup – Enable or disable the schema markup for SEO.

Examples and Usage

Basic example – Display all testimonials without any specific order or filter.

[testimonials_shortcode]

Advanced examples – Display testimonials with specific parameters.

Displaying testimonials with a specific category. The testimonials will be filtered by the category ‘customer-review’.

[testimonials_shortcode category='customer-review']

Displaying testimonials with a specific count and order. The testimonials will be limited to 5 and ordered by date in descending order.

[testimonials_shortcode count=5 orderby='date' order='DESC']

Displaying testimonials with pagination. The testimonials will be divided into pages with 10 testimonials per page.

[testimonials_shortcode paginate=true testimonials_per_page=10]

Displaying testimonials with a specific theme. The testimonials will be displayed with the theme ‘dark_grey-classic_style’.

[testimonials_shortcode theme='dark_grey-classic_style']

PHP Function Code

In case you have difficulties debugging what causing issues with [easy_testimonials] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( $this->shortcodes['testimonials_shortcode'], array($this, 'outputTestimonials') );

Shortcode PHP function:

function outputTestimonials($atts){ 
		
		//load shortcode attributes into an array
		$atts = shortcode_atts( array(
			'testimonials_link' => get_option('testimonials_link'),
			'show_title' => 0,
			'count' => -1,
			'body_class' => 'testimonial_body',
			'author_class' => 'testimonial_author',
			'id' => '',
			'use_excerpt' => false,
			'reveal_full_content' => false,
			'category' => '',
			'show_thumbs' => get_option('testimonials_image', true),
			'short_version' => false,
			'orderby' => 'date',//'none','ID','author','title','name','date','modified','parent','rand','menu_order'
			'order' => 'DESC', // 'ASC, DESC''
			'show_rating' => 'stars',
			'paginate' => false,
			'testimonials_per_page' => 10,
			'theme' => get_option('testimonials_style', 'light_grey-classic_style'),
			'show_date' => true,
			'show_other' => true,
			'width' => false,
			'hide_view_more' => true,
			'output_schema_markup' => get_option('easy_t_output_schema_markup', true)
		), $atts );
		
		if ( $atts['reveal_full_content'] ) {
			$atts['use_excerpt'] = true;
		}
						
		extract($atts);
				
		//if a bad value is passed for count, set it to -1 to load all testimonials
		//if $paginate is set to "all", this shortcode was made from a widget 
		//and we need to set the count to -1 to load all testimonials
		if(!is_numeric($count) || $paginate == "all"){
			$count = -1;
		}
		
		//if we are paging the testimonials, set the $count to the number of testimonials per page
		//sometimes $paginate is set, but is set to "all" (from the Widget) -
		//this indicates that we want to show every testimonial and not page them
		if($paginate && $paginate != "all"){
			$count = $testimonials_per_page;
		}
		
		$i = 0;
		
		$args = array( 
			'post_type' => 'testimonial',
			'posts_per_page' => $count,
			'orderby' => $orderby,
			'order' => $order
		);
		
		// add category filter if specified
		if ( !empty($category) ) {
			// IMPORTANT: tax_query is an ARRAY of ARRAYs
			$args['tax_query'] = array(
				array(
					'taxonomy' => 'easy-testimonial-category',
					'field'    => 'slug',
					'terms'    => $category,
				)
			);
		}
		
		// handle paging
		$nopaging = ($testimonials_per_page <= 0);

		$testimonial_page = 1;
		if ( get_query_var('testimonial_page') ) {
			$testimonial_page = get_query_var('testimonial_page');
		}
		$paged = $testimonial_page;
		
		if (!$nopaging && $paginate && $paginate != "all") {
			//if $nopaging is false and $paginate is true, or max (but not "all"), then $testimonials_per_page is greater than 0 and the user is trying to paginate them
			//sometimes paginate is true, or 1, or max -- they all indicate the same thing.  "max" comes from the widget, true or 1 come from the shortcode / old instructions
			$args['posts_per_page'] = $testimonials_per_page;
			$args['paged'] = $paged;
		}
		
		ob_start();
		
		//load testimonials
		$testimonials_loop = $this->get_testimonials_loop($args);
		
		$testimonials = $testimonials_loop->get_posts();
		
		foreach($testimonials as $this_testimonial){
			//create a new testimonial object by passing in the current testimonial			
			$data = array(
				'testimonial' => $this_testimonial,
				'atts' => $atts
			);
			
			$testimonial = new GP_Testimonial($data, $this->config);
			
			//output the testimonials HTML
			$testimonial->render();
		}
		
		//output the pagination links, if instructed to do so
		//TBD: make all labels controllable via settings
		if($paginate){
			$pagination_link_template = $this->get_pagination_link_template('testimonial_page');
			
			?>
			<div class="easy_t_pagination">                               
				<?php
				echo wp_kses_post(paginate_links( array(
					'base' => $pagination_link_template,
					'format' => '?testimonial_page=%#%',
					'current' => max( 1, $paged ),
					'total' => $testimonials_loop->max_num_pages
				) ) );
				?>
			</div>  
			<?php
		}
		
		wp_reset_postdata();
		
		$content = ob_get_contents();
		ob_end_clean();
		
		return apply_filters('easy_t_testimonials_html', $content);
	}

Code file location:

easy-testimonials/easy-testimonials/easy-testimonials.php

Easy Testimonials [testimonials_cycle] Shortcode

The Easy Testimonials plugin shortcode is a powerful tool that dynamically generates and displays customer testimonials on your WordPress site. It allows customization of various attributes such as the number of testimonials displayed, transition style, show/hide title, and more. It also supports random testimonial display and provides options for auto height calculation, category filtering, and testimonial ordering. The shortcode ensures seamless integration of testimonials, enhancing user engagement and trust.

Shortcode: [testimonials_cycle]

Parameters

Here is a list of all possible testimonials_cycle_shortcode shortcode parameters and attributes:

  • testimonials_link – Link to the page with all testimonials.
  • show_title – Set to 1 to display testimonial title, 0 to hide it.
  • count – Number of testimonials to display, -1 for all.
  • transition – The transition effect between testimonials.
  • show_thumbs – Set to true to display testimonial images, false to hide them.
  • timer – Time duration between testimonial transitions in milliseconds.
  • container – Deprecated, use auto_height instead.
  • use_excerpt – If true, display testimonial excerpt instead of full text.
  • auto_height – Set height calculation method, ‘container’ or ‘calc’.
  • category – Show testimonials from a specific category.
  • body_class – CSS class for the testimonial content.
  • author_class – CSS class for the testimonial author.
  • random – If set, testimonials will be displayed in random order.
  • orderby – Parameter to sort retrieved testimonials by.
  • order – Designates the ascending or descending order of the ‘orderby’ parameter.
  • pager – If true, display pagination for the testimonials.
  • show_pager_icons – If true, display icons in the pagination.
  • show_rating – Display rating, ‘stars’ for star rating.
  • testimonials_per_slide – Number of testimonials to display per slide.
  • theme – Set the theme style for the testimonials.
  • show_date – If true, display the date of the testimonial.
  • show_other – If true, display other information of the testimonial.
  • pause_on_hover – If true, pause the slider on hover.
  • prev_next – If true, display previous and next navigation.
  • width – Set the width of the testimonial slider.
  • paused – If true, the slider will be paused initially.
  • display_pagers_above – If true, display pagination above the slider.
  • hide_view_more – Set to 1 to hide the ‘view more’ button, 0 to display it.
  • show_log – If true, display debugging log, false to hide it.
  • output_schema_markup – If true, output schema markup for SEO.

Examples and Usage

Basic example – A simple usage of the shortcode to display testimonials in a cycle with default settings.

[testimonials_cycle_shortcode /]

Advanced examples

Displaying testimonials in a cycle with a specific transition effect (scrollHorz), a custom timer (7000 milliseconds), and auto height adjustment based on the container.

[testimonials_cycle_shortcode transition="scrollHorz" timer="7000" auto_height="container" /]

Displaying testimonials in a cycle with custom classes for the testimonial body and author, a random display order, and a specified category.

[testimonials_cycle_shortcode body_class="custom_body" author_class="custom_author" random="true" category="customer_reviews" /]

Displaying testimonials in a cycle with a set number of testimonials per slide, a specific theme, and enabling the display of date and other information.

[testimonials_cycle_shortcode testimonials_per_slide="3" theme="dark_grey-classic_style" show_date="true" show_other="true" /]

PHP Function Code

In case you have difficulties debugging what causing issues with [testimonials_cycle_shortcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( $this->shortcodes['testimonials_cycle_shortcode'], array($this, 'outputTestimonialsCycle') );

Shortcode PHP function:

function outputTestimonialsCycle($atts){
		//load shortcode attributes into an array
		$atts = shortcode_atts( array(
			'testimonials_link' => get_option('testimonials_link'),
			'show_title' => 0,
			'count' => -1,
			'transition' => 'scrollHorz',
			'show_thumbs' => get_option('testimonials_image', true),
			'timer' => '5000',
			'container' => false,//deprecated, use auto_height instead
			'use_excerpt' => false,
			'auto_height' => 'container',
			'category' => '',
			'body_class' => 'testimonial_body',
			'author_class' => 'testimonial_author',
			'random' => '',
			'orderby' => 'date',//'none','ID','author','title','name','date','modified','parent','rand','menu_order'
			'order' => 'DESC', // 'ASC, DESC''
			'pager' => false,
			'show_pager_icons' => false,
			'show_rating' => 'stars',
			'testimonials_per_slide' => 1,
			'theme' => get_option('testimonials_style', 'light_grey-classic_style'),
			'show_date' => true,
			'show_other' => true,
			'pause_on_hover' => false,
			'prev_next' => false,
			'width' => false,
			'paused' => false,
			'display_pagers_above' => false,
			'hide_view_more' => 0,
			'show_log' => ( defined('WP_DEBUG') && true === WP_DEBUG ) ? 1 : 0,
			'output_schema_markup' => get_option('easy_t_output_schema_markup', true)
		), $atts );

		extract($atts);
				
		if(!is_numeric($count)){
			$count = -1;
		}
		
		ob_start();
		
		$i = 0;
		
		if(!$this->config->is_pro && !in_array($transition, array('fadeOut','fade','scrollHorz'))){
			$transition = 'fadeout';
		}
		
		//use random WP query to be sure we aren't just randomly sorting a chronologically queried set of testimonials
		//this prevents us from just randomly ordering the same 5 testimonials constantly!
		if($random){
			$orderby = "rand";
		}

		//determine if autoheight is set to container or to calculate
		//not sure why i did this so backwards to begin with!  oh well...
		if($container){
			$container = "container";
		}
		if($auto_height == "calc"){
			$container = "calc";
		} else if($auto_height == "container"){
			$container = "container";
		}
		
		//generate a random number to have a unique wrapping class on each slideshow
		//this should prevent controls that effect more than one slideshow on a page
		$target = rand();
		
		//use the width for the slideshow wrapper, to keep the previous/next buttons and pager icons within the desired layout
		$width = $width ? 'style="width: ' . $width . '"' : 'style="width: ' . get_option('easy_t_width','') . '"';
		
		//load testimonials
		$testimonials_loop = $this->get_testimonials_loop(array( 'post_type' => 'testimonial','posts_per_page' => $count, 'orderby' => $orderby, 'order' => $order, 'easy-testimonial-category' => $category));
		//for tracking number of testimonials in this loop
		$count = $testimonials_loop->post_count;

		$testimonials = $testimonials_loop->get_posts();
		
		?>
		<div class="easy-t-slideshow-wrap <?php echo esc_attr("easy-t-{$target}");?>" <?php echo esc_attr($width); ?>>
		
			<?php //only display cycle controls if there is more than one testimonial ?>
			<?php if($display_pagers_above && $count > 1): ?>
			<div class="easy-t-cycle-controls">				
				<?php if($prev_next):?><div class="cycle-prev easy-t-cycle-prev"><?php echo esc_html(get_option('easy_t_previous_text', '<< Prev')); ?></div><?php endif; ?>
				<?php if($pager || $show_pager_icons ): ?>
					<div class="easy-t-cycle-pager"></div>
				<?php endif; ?>
				<?php if($prev_next):?><div class="cycle-next easy-t-cycle-next"><?php echo esc_html(get_option('easy_t_next_text', 'Next >>')); ?></div><?php endif; ?>			
			</div>	
			<?php endif; ?>
				
			<?php
				//thanks, wpgaijin
				//https://wordpress.org/support/topic/still-got-bugs
				$data_cycle_array = array(
					'data_cycle_fx'             => 'data-cycle-fx="'. $transition .'"',
					'data_cycle_timeout'        => 'data-cycle-timeout="'. $timer . '"',
					'data_cycle_slides'         => 'data-cycle-slides="div.testimonial_slide"',
					'data_cycle_auto_height'    => ( $container ) ? 'data-cycle-auto-height="' . $container .'"' : '',
					'data_cycle_random'         => ( $random ) ? 'data-cycle-random="true"' : '',
					'data_cycle_pause_on_hover' => ( $pause_on_hover ) ? 'data-cycle-pause-on-hover="true"' : '',
					'data_cycle_paused'         => ( $paused ) ? 'data-cycle-paused="true"' : '',
					'data_cycle_prev'           => ( $prev_next ) ? 'data-cycle-prev=".easy-t-' . $target .' .easy-t-cycle-prev"' : '',
					'data_cycle_next'           => ( $prev_next ) ? 'data-cycle-next=".easy-t-' . $target .' .easy-t-cycle-next"' : '',
					'data_cycle_pager'          => ( $pager || $show_pager_icons ) ? 'data-cycle-pager=".easy-t-'. $target .' .easy-t-cycle-pager"' : '',
					'data-cycle-log'			=> ( !$show_log ) ? 'data-cycle-log="false"' : '',
					'data-cycle-fix-carousel'	=> ( $transition == "carousel" ) ? 'data-cycle-fix-carousel="1"' : ''
				);
				
				if ($transition == "carousel"){
					$data_cycle_array['data-cycle-fix-carousel-visible'] = 'data-cycle-carousel-visible="'.$testimonials_per_slide.'"';
					$data_cycle_array['data-cycle-fix-carousel-fluid'] = 'data-cycle-carousel-fluid="true"';
				}

				$data_cycle = implode( ' ', $data_cycle_array );
				$data_cycle = rtrim( $data_cycle );
				?>
				<div class="cycle-slideshow" <?php echo esc_html($data_cycle); ?>>
			<?php
			
			$counter = 0;

			foreach($testimonials as $this_testimonial){
				//hide all but the first slide
				if($counter == 0){
					$testimonial_display = '';
				} else {
					$testimonial_display = 'style="display:none;"';
				}
				
				//create slide div
				//if this is a carousel, bypass the wrapping multiple testimonials in one slide step
				if($counter%$testimonials_per_slide == 0 || $transition == "carousel"){
					echo "<div { " . esc_html($testimonial_display) . "} class=\"testimonial_slide\">";
				}
				
				$counter ++;
				
				//create a new testimonial object by passing in the current testimonial			
				$data = array(
					'testimonial' => $this_testimonial,
					'atts' => $atts
				);
				
				$testimonial = new GP_Testimonial($data, $this->config);

				//output the testimonials HTML
				$testimonial->render();
				
				//close slide
				//if this is a carousel, bypass the wrapping multiple testimonials in one slide step
				if($counter%$testimonials_per_slide == 0 || $transition == "carousel"){
					echo "</div>";
				}
			}
			
			wp_reset_postdata();
			
			?>
			</div>
			
			<?php //only display cycle controls if there is more than one testimonial ?>
			<?php if(!$display_pagers_above && $count > 1): ?>
			<div class="easy-t-cycle-controls">				
				<?php if($prev_next):?><div class="cycle-prev easy-t-cycle-prev"><?php echo esc_html(get_option('easy_t_previous_text', '<< Prev')); ?></div><?php endif; ?>
				<?php if($pager || $show_pager_icons ): ?>
					<div class="easy-t-cycle-pager"></div>
				<?php endif; ?>
				<?php if($prev_next):?><div class="cycle-next easy-t-cycle-next"><?php echo esc_html(get_option('easy_t_next_text', 'Next >>')); ?></div><?php endif; ?>			
			</div>	
			<?php endif; ?>
			
		</div><!-- end slideshow wrap --><?php
		
		$content = ob_get_contents();
		ob_end_clean();
		
		return apply_filters( 'easy_t_testimonials_cyle_html', $content);
	}

Code file location:

easy-testimonials/easy-testimonials/easy-testimonials.php

Easy Testimonials [easy_t_testimonials_grid] Shortcode

The Easy Testimonials shortcode is a powerful tool that enables the display of testimonials in a grid format on your WordPress site. This shortcode uses various attributes, allowing customization of the testimonials grid. These attributes include the number of testimonials to display, the order of testimonials, and the design elements of the grid. It also enables pagination, ensuring a clean and organized display.

Shortcode: [easy_t_testimonials_grid]

Parameters

Here is a list of all possible easy_t_testimonials_grid_shortcode shortcode parameters and attributes:

  • testimonials_link – Link for the testimonials, if any.
  • show_title – Show or hide the title of testimonials.
  • count – Number of testimonials to display.
  • body_class – CSS class for the text of testimonials.
  • author_class – CSS class for the author of testimonials.
  • id – Identifier of a specific testimonial.
  • ids – Identifiers of multiple testimonials.
  • use_excerpt – Use summary of testimonials instead of full text.
  • reveal_full_content – Show full text of testimonials on click.
  • category – Category of testimonials to display.
  • show_thumbs – Show or hide thumbnail images of testimonials.
  • short_version – Display shortened version of testimonials.
  • orderby – Order of testimonials display based on parameters.
  • order – Ascending or descending order of testimonials.
  • show_rating – Show or hide the ratings of testimonials.
  • paginate – Enable or disable pagination for testimonials.
  • testimonials_per_page – Number of testimonials to show per page.
  • theme – Theme style for the testimonials.
  • show_date – Show or hide the date of testimonials.
  • show_other – Show or hide other details of testimonials.
  • width – Width of testimonials section.
  • cols – Number of testimonials columns to display.
  • grid_width – Width of testimonials grid.
  • grid_spacing – Spacing between testimonials in grid.
  • grid_class – CSS class for the testimonials grid.
  • cell_width – Width of each cell in the testimonials grid.
  • responsive – Enable or disable responsiveness of testimonials grid.
  • equal_height_rows – Enable or disable equal height of testimonials rows.
  • hide_view_more – Hide or show the ‘View More’ button.
  • output_schema_markup – Output schema markup for testimonials.

Examples and Usage

Basic example – Display all testimonials in a grid format.

[easy_t_testimonials_grid]

Advanced examples

Display a grid of testimonials from a specific category, ordered by date in ascending order, and limit the number of testimonials to 5.

[easy_t_testimonials_grid category='customer-reviews' orderby='date' order='ASC' count='5']

Show a grid of testimonials with a specific ID, display the title, and use excerpts instead of full testimonials.

[easy_t_testimonials_grid_shortcode id='123' show_title='1' use_excerpt='true']

Display testimonials in a grid with 4 columns, set the grid width to 100%, and use a custom grid class for additional styling.

[easy_t_testimonials_grid cols='4' grid_width='100%' grid_class='my-custom-grid']

Show a paginated grid of testimonials, displaying 10 testimonials per page.

[easy_t_testimonials_grid paginate='true' testimonials_per_page='10']

These examples illustrate how to use the shortcode with different parameters to customize the display of testimonials on your WordPress website.

PHP Function Code

In case you have difficulties debugging what causing issues with [easy_t_testimonials_grid_shortcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( $this->shortcodes['testimonials_grid_shortcode'], array($this, 'easy_t_testimonials_grid_shortcode') );

Shortcode PHP function:

function easy_t_testimonials_grid_shortcode($atts)
	{
		// load shortcode attributes into an array
		// note: these are mostly the same attributes as [testimonials] shortcode
		$atts = shortcode_atts( array(
			'testimonials_link' => get_option('testimonials_link'),
			'show_title' => 0,
			'count' => -1,
			'body_class' => 'testimonial_body',
			'author_class' => 'testimonial_author',
			'id' => '',
			'ids' => '', // i've heard it both ways
			'use_excerpt' => false,
			'reveal_full_content' => false,
			'category' => '',
			'show_thumbs' => get_option('testimonials_image', true),
			'short_version' => false,
			'orderby' => 'date',//'none','ID','author','title','name','date','modified','parent','rand','menu_order'
			'order' => 'DESC', // 'ASC, DESC''
			'show_rating' => 'stars',
			'paginate' => false,
			'testimonials_per_page' => 10,
			'theme' => get_option('testimonials_style', 'light_grey-classic_style'),
			'show_date' => true,
			'show_other' => true,
			'width' => false,
			'cols' => 3, // 1-10
			'grid_width' => false,
			'grid_spacing' => false,
			'grid_class' => '',
			'cell_width' => false,
			'responsive' => true,
			'equal_height_rows' => false,
			'hide_view_more' => 0,
			'output_schema_markup' => get_option('easy_t_output_schema_markup', true)
		), $atts );
		
		if ( $atts['reveal_full_content'] ) {
			$atts['use_excerpt'] = true;
		}
						
		extract( $atts );
		
		// allow ids or id to be passed in
		if ( empty($id) && !empty($ids) ) {
			$id = $ids;
		}
				
		//if a bad value is passed for count, set it to -1 to load all testimonials
		//if $paginate is set to "all", this shortcode was made from a widget 
		//and we need to set the count to -1 to load all testimonials
		if(!is_numeric($count) || $paginate == "all"){
			$count = -1;
		}
		
		//if we are paging the testimonials, set the $count to the number of testimonials per page
		//sometimes $paginate is set, but is set to "all" (from the Widget) -
		//this indicates that we want to show every testimonial and not page them
		if($paginate && $paginate != "all"){
			$count = $testimonials_per_page;
		}
		
		$testimonials_output = '';
		$col_counter = 1;
		$row_counter = 0;
		
		if ($equal_height_rows) {
			wp_enqueue_script('easy-testimonials-grid');
		}
		
		if ( empty($rows) ) {
			$rows  = -1;
		}
		
		// make sure $cols is between 1 and 10
		$cols = max( 1, min( 10, intval($cols) ) );
		
		// create CSS for cells (will be same on each cell)
		$cell_style_attr = '';
		$cell_css_rules = array();

		if ( !empty($grid_spacing) && intval($grid_spacing) > 0 ) {
			$coefficient = intval($grid_spacing) / 2;
			$unit = ( strpos($grid_spacing, '%') !== false ) ? '%' : 'px';
			$cell_margin = $coefficient . $unit;
			$cell_css_rules[] = sprintf('margin-left: %s', $cell_margin);
			$cell_css_rules[] = sprintf('margin-right: %s', $cell_margin);
		}

		if ( !empty($cell_width) && intval($cell_width) > 0 ) {
			$cell_css_rules[] = sprintf('width: %s', $cell_width);
		}

		$cell_style_attr = !empty($cell_css_rules) ? sprintf('style="%s"', implode(';', $cell_css_rules) ) : '';
		
		// combine the rules into a re-useable opening <div> tag to be used for each cell
		$cell_div_start = sprintf('<div class="easy_testimonials_grid_cell" %s>', $cell_style_attr);
		
		// grab all requested testimonials and build one cell (in HTML) for each
		// note: using WP_Query instead of get_posts in order to respect pagination
		//    	 more info: http://wordpress.stackexchange.com/a/191934
		$args = array(
			'post_type' => 'testimonial',
			'posts_per_page' => $count,
			'easy-testimonial-category' => $category,
			'orderby' => $orderby,
			'order' => $order
		);
		
		// handle paging
		$nopaging = ($testimonials_per_page <= 0);
		$paged = !empty($_REQUEST['testimonial_page']) && intval($_REQUEST['testimonial_page']) > 0 ? intval($_REQUEST['testimonial_page']) : 1;
		if (!$nopaging && $paginate && $paginate != "all") {
			//if $nopaging is false and $paginate is true, or max (but not "all"), then $testimonials_per_page is greater than 0 and the user is trying to paginate them
			//sometimes paginate is true, or 1, or max -- they all indicate the same thing.  "max" comes from the widget, true or 1 come from the shortcode / old instructions
			$args['posts_per_page'] = $testimonials_per_page;
			$args['paged'] = $paged;
		}
		
		// restrict to specific posts if requested
		if ( !empty($id) ) {
			$args['post__in'] = array_map('intval', explode(',', $id));
		}
		
		$testimonials_loop = $this->get_testimonials_loop($args);
		
		$testimonials = $testimonials_loop->get_posts();
		
		$in_row = false;
		foreach( $testimonials as $this_testimonial ) {

			if ($col_counter == 1) {
				$in_row = true;
				$row_counter++;
				$testimonials_output .= sprintf('<div class="easy_testimonials_grid_row easy_testimonials_grid_row_%d">', $row_counter);
			}
					
			$testimonials_output .= $cell_div_start;
		
			//create a new testimonial object by passing in the current testimonial			
			$data = array(
				'testimonial' => $this_testimonial,
				'atts' => $atts
			);
			
			$testimonial = new GP_Testimonial($data, $this->config);
			
			//load output into variable to concatenate
			ob_start();
			$testimonial->render();
			$ob_content = ob_get_contents();
			ob_end_clean();
		
			$testimonials_output .= $ob_content;
			
			$testimonials_output .= '</div>';

			if ($col_counter == $cols) {
				$in_row = false;
				$testimonials_output .= '</div><!--easy_testimonials_grid_row-->';
				$col_counter = 1;
			} else {
				$col_counter++;
			}
		} // endwhile;
		
		// close any half finished rows
		if ($in_row) {
			$testimonials_output .= '</div><!--easy_testimonials_grid_row-->';
		}
		
		//output the pagination links, if instructed to do so
		//TBD: make all labels controllable via settings
		if($paginate){
			$pagination_link_template = $this->get_pagination_link_template('testimonial_page');
			
			$testimonials_output .= '<div class="easy_t_pagination">';                           
			$testimonials_output .= paginate_links(array(
										'base' => $pagination_link_template,
										'format' => '?testimonial_page=%#%',
										'current' => max( 1, $paged ),
										'total' => $testimonials_loop->max_num_pages
									));
			$testimonials_output .= '</div>  ';
		}
		
		// restore globals to their original values (i.e, $post and friends)
		wp_reset_postdata();
			
		// setup the grid's CSS, insert the grid of testimonials (the cells) 
		// into the grid, add a clearing div, and return the whole thing
		$grid_classes = array(
			'easy_testimonials_grid',
			'easy_testimonials_grid_' . $cols
		);
		
		if ($responsive) {
			$grid_classes[] = 'easy_testimonials_grid_responsive';
		}
		
		if ($equal_height_rows) {
			$grid_classes[] = 'easy_testimonials_grid_equal_height_rows';
		}

		// add any grid classes specified by the user
		if ( !empty($grid_class) ) {
			$grid_classes = array_merge( $grid_classes, explode(' ', $grid_class) );
		}
		
		// combine all classes into an class attribute
		$grid_class_attr = sprintf( 'class="%s"', implode(' ', $grid_classes) );
		
		// add all style rules for the grid (currently, only specifies width)
		$grid_css_rules = array();
		if ( !empty($grid_width) && intval($grid_width) > 0 ) {
			$grid_css_rules[] = sprintf('width: %s', $grid_width);
		}
		
		// combine all CSS rules into an HTML style attribute
		$grid_style_attr = sprintf( 'style="%s"', implode(';', $grid_css_rules) );
			
		// add classes and CSS rules to the grid, insert cells, return result
		$grid_template = '<div %s %s>%s</div>';
		$grid_html = sprintf($grid_template, $grid_class_attr, $grid_style_attr, $testimonials_output);
		return $grid_html;
	}

Code file location:

easy-testimonials/easy-testimonials/easy-testimonials.php

Easy Testimonials [testimonials_count] Shortcode

The Easy Testimonials shortcode is a powerful tool that displays the count of testimonials. It allows customization of category, status, and aggregate rating display.

Shortcode: [testimonials_count_shortcode]

Parameters

Here is a list of all possible testimonials_count_shortcode shortcode parameters and attributes:

  • category – specifies the category of testimonials to count.
  • status – indicates the publication status of testimonials.
  • show_aggregate_rating – decides whether to display combined ratings or not.
  • show_aggregate_rating_stars – controls the display of rating stars.
  • show_aggregate_rating_text – determines if the rating text will be shown.

Examples and Usage

Basic example – Show the total number of testimonials

[easy-testimonials-count]

This shortcode will output the total number of published testimonials. It’s a simple way to display the count of testimonials on your site.

Advanced examples

Show the total number of testimonials in a specific category

[easy-testimonials-count category="customer-service"]

In this example, the shortcode will output the number of published testimonials that are categorized under ‘customer-service’. You can replace ‘customer-service’ with any category slug on your WordPress site.

Show the total number of testimonials and include aggregate rating

[easy-testimonials-count show_aggregate_rating=true]

This shortcode will display the total count of testimonials and also include the aggregate rating. This is useful if you want to show the overall rating of your testimonials along with the count.

Show the total number of testimonials, include aggregate rating, and show rating stars

[easy-testimonials-count show_aggregate_rating=true show_aggregate_rating_stars=true]

This shortcode will output the total count of testimonials, the aggregate rating, and also display the rating stars. It’s a comprehensive way to showcase your testimonials and their overall rating.

PHP Function Code

In case you have difficulties debugging what causing issues with [testimonials_count_shortcode] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( $this->shortcodes['testimonials_count_shortcode'], array($this, 'outputTestimonialsCount') );

Shortcode PHP function:

function outputTestimonialsCount($atts){
		//load shortcode attributes into an array
		extract( shortcode_atts( array(
			'category' => '',
			'status' => 'publish',
			'show_aggregate_rating' => false,
			'show_aggregate_rating_stars' => false,
			'show_aggregate_rating_text' => true
		), $atts ) );
		
		$output = $this->easy_testimonials_count($category, $status, $show_aggregate_rating, $show_aggregate_rating_stars, $show_aggregate_rating_text);
		
		return $output;
	}

Code file location:

easy-testimonials/easy-testimonials/easy-testimonials.php

Easy Testimonials [easy_t_search_testimonials] Shortcode

The Easy Testimonials shortcode is a tool that enables the search function specifically for testimonials on your site. This shortcode restricts the search scope to custom post types. It first applies a filter to the search form, performs the search within testimonials, then removes the filter.

Shortcode: [easy_t_search_testimonials]

Examples and Usage

Basic example – Showcases a simple usage of the ‘easy_t_search_testimonials’ shortcode without any additional parameters.

[easy_t_search_testimonials /]

PHP Function Code

In case you have difficulties debugging what causing issues with [easy_t_search_testimonials] shortcode, check below the related PHP functions code.

Shortcode line:

add_shortcode( 'easy_t_search_testimonials', array($this, 'easy_t_search_form_shortcode') );

Shortcode PHP function:

function easy_t_search_form_shortcode()
	{
		add_filter('get_search_form', array($this, 'easy_t_restrict_search_to_custom_post_type'), 10);
		$search_html = get_search_form();
		remove_filter('get_search_form', array($this, 'easy_t_restrict_search_to_custom_post_type'));
		return $search_html;
	}

Code file location:

easy-testimonials/easy-testimonials/easy-testimonials.php

Conclusion

Now that you’ve learned how to embed the Easy Testimonials Plugin shortcodes, understood the parameters, and seen code examples, it’s easy to use and debug any issue that might cause it to ‘not work’. If you still have difficulties with it, don’t hesitate to leave a comment below.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *