YITH Proteo Toolkit Shortcode

Below, you’ll find a detailed guide on how to add the YITH Proteo Toolkit Shortcode to your WordPress website, including its parameters, examples, and PHP function code. Additionally, we’ll assist you with common issues that might cause the YITH Proteo Toolkit Plugin shortcode not to show or not to work correctly.

Before starting, here is an overview of the YITH Proteo Toolkit Plugin and the shortcodes it provides:

Plugin Icon
YITH Proteo Toolkit

"YITH Proteo Toolkit is a powerful WordPress plugin that enhances the functionality of YITH Proteo theme. It provides additional customization options, ensuring your website stands out."

★★★★★ (1) Active Installs: 3000+ Tested with: 6.2.3 PHP Version: 7.2
Included Shortcodes:
  • [proteo_testimonials]

YITH Proteo Toolkit [proteo_testimonials] Shortcode

The YITH Proteo Toolkit shortcode, ‘proteo_testimonials’, is designed to fetch and display testimonials from your WordPress site. It allows customization with attributes like ‘names’, ‘count’, ‘layout’, and ‘elements’. These attributes enable you to specify the testimonials to display, the number, the layout (list or grid), and the elements to show. It retrieves testimonials based on the provided attributes, and if none match the criteria, it returns an empty string. The shortcode then locates the template for displaying the testimonials and renders it.

Shortcode: [proteo_testimonials]

Parameters

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

  • names – a list of testimonial names separated by commas
  • count – the number of testimonials to display
  • layout – the display style, either ‘grid’ or ‘list’
  • elements – a list of testimonial elements to show, separated by commas

Examples and Usage

Basic example – A shortcode to display all testimonials in a list format.

[proteo_testimonials count="-1" layout="list"]

Advanced examples

Displaying a specific number of testimonials in a grid format.

[proteo_testimonials count="5" layout="grid"]

Displaying testimonials from specific names in a list format.

[proteo_testimonials names="John, Jane, Doe" layout="list"]

Customizing the elements to show in the testimonials.

[proteo_testimonials elements="name, title, company" layout="grid"]

Combining different parameters to display a specified number of testimonials from specific names in a grid format with selected elements.

[proteo_testimonials names="John, Jane, Doe" count="3" elements="name, title, company" layout="grid"]

PHP Function Code

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

Shortcode line:

add_shortcode( 'proteo_testimonials', 'yith_proteo_toolkit_proteo_testimonials_sc' );

Shortcode PHP function:

                    function yith_proteo_toolkit_proteo_testimonials_sc( $atts ) {
	// Attributes.
	$atts = shortcode_atts(
		array(
			'names'    => '', // comma separated list of testimonial names.
			'count'    => '-1',
			'layout'   => 'list', // grid or list.
			'elements' => '', // comma separated list of testimonial elements to show.
		),
		$atts,
		'proteo_testimonials'
	);

	$args = array(
		'numberposts' => $atts['count'],
		'post_type'   => 'proteo_testimonials',
		'orderby'     => 'date',
		'order'       => 'DESC',
		'post_status' => 'publish',
		'fields'      => 'ids',
	);

	$proteo_testimonials_id_array         = get_posts( $args );
	$proteo_testimonials_layout           = $atts['layout'];
	$proteo_testimonials_elements_to_show = $atts['elements'];
	$proteo_testimonials_names_to_show    = $atts['names'];

	if ( empty( $proteo_testimonials_id_array ) ) {
		return '';
	}

	$default_path  = YITH_PROTEO_TOOLKIT_TEMPLATE_PATH;
	$theme_path    = 'yith-proteo-toolkit/';
	$template_name = 'proteo-testimonials.php';

	$template = locate_template(
		array(
			trailingslashit( $theme_path ) . $template_name,
			$template_name,
		)
	);

	if ( ! $template ) {
		$template = trailingslashit( $default_path ) . $template_name;
	}

	if ( ! file_exists( $template ) ) {
		return '';
	}

	ob_start();

	include $template;

	return ob_get_clean();

}
                    

Code file location:

yith-proteo-toolkit/yith-proteo-toolkit/includes/testimonials-module/shortcodes/shortcodes.php

Conclusion

Now that you’ve learned how to embed the YITH Proteo Toolkit Plugin shortcode, 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 *