Knowledge Base/Testimonials Widget/Frequently Asked Questions

How do I use the theme functions `testimonials()` and `testimonials_slider()`?

Michael Cannon
posted this on April 29, 2013, 22:41

In your theme’s functions.php file, place code similar to the following for the configuration you need.

A basic testimonial list or widget with no options, but using globally defined defaults from Testimonials > Settings.

<?php echo testimonials(); ?>
<?php echo testimonials_slider(); ?>

Testimonial list or widget with options, but for those options not specifically set are then defined by defaults from Testimonials > Settings.

<?php

// The following argument configuration selects 5 testimonials of the "product" category, having the "widget" tag.
// $args is an optional array of desired shortcode options
$args = array(
    'category' => 'product',
    'tags' => 'widget',
    'limit' => 5,
);

// Displays the testimonials as a list into your theme directly
echo testimonials( $args );

// The following argument configuration selects testimonials of the "review" tag and sets a slower rotation speed for the display widget
$args = array(
    'tags' => 'review',
    'refresh_interval' => 15,
);

// Displays the testimonials as a rotating widget into your theme directly
echo testimonials_slider( $args );

// $widget_number is an optional, arbitrarily number (probably safe between 1,000 and 9,999) that helps create a uniquely identifiable testimonials widget display instance.
$widget_number = 1234;
// Displays the testimonials as a rotating widget into your theme directly with specific class .testimonials-widget-testimonials1234 echo testimonials_slider( $args, $widget_number ); ?>

In case of Fatal error: Call to undefined function testimonials_slider() in…, please try including testimonials-widget.php like the following.

<?php 
include_once( WP_PLUGIN_DIR . '/testimonials-widget/testimonials-widget.php' );
echo testimonials_slider(); 
?>

All Options

Listing all options here is not feasible. However, here's links to the pages that do contain such information. Further, once you install testimonials there's an example page at WordPress Admin > Testimonials > e.g. Shortcodes listing various configurations. Lastly, check out the live demo page.

 

Comments

User photo
Adam Abrams

Hi Michael! Hey, it would be great (and newbie-friendly) to do a couple of things here:

- List ALL arguments, with a note that they're all optional of course;

- List the detailed _list and _widget code blocks separately.

Thanks!

Adam

April 12, 2014, 14:13
User photo
Michael Cannon
Aihrus

@Adam, an "All Options" section was added with links to options and examples.

April 12, 2014, 18:24