Below, you’ll find a detailed guide on how to add the BNE 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 BNE Testimonials Plugin shortcodes not to show or not to work correctly.
Before starting, here is an overview of the BNE Testimonials Plugin and the shortcodes it provides:
"BNE Testimonials is a powerful WordPress plugin that allows you to display and manage customer testimonials with ease. Enhance credibility and strengthen your brand reputation with this tool."
- [bne_testimonials_list]
- [bne_testimonials_slider]
- [bne_testimonials]
BNE Testimonials [bne_testimonials_list] Shortcode
The ‘bne_testimonials_list’ shortcode from the BNE Testimonials plugin displays a list of testimonials. It allows customization of the number of posts, order, title, featured image, and more.
Shortcode: [bne_testimonials_list]
Parameters
Here is a list of all possible bne_testimonials_list shortcode parameters and attributes:
post
– Determines the number of testimonials to display.order
– Specifies the order of testimonials (by date, title, or random).order_direction
– Sets the direction of the order (ascending or descending).name
– Controls the display of the testimonial title.image
– Controls the display of the featured image.image_style
– Defines the style of the profile image (circle, square, flat-circle, flat-square).category
– Filters testimonials by specified category.lightbox_rel
– Enables the use of a lightbox command on the featured image.class
– Adds a custom CSS class to the testimonial.id
– Assigns a unique identifier to the testimonial.
Examples and Usage
Basic example – A simple usage of the shortcode to display testimonials in a list format.
[bne_testimonials_list]
Advanced examples
Displaying a specified number of testimonials, ordered by title in ascending order, with the featured image displayed in a flat-square style.
[bne_testimonials_list post='5' order='title' order_direction='ASC' image_style='flat-square']
Displaying testimonials from a specific category, without the post title or featured image, and with a custom class for additional styling.
[bne_testimonials_list name='false' image='false' category='customer-reviews' class='custom-testimonials']
Using the shortcode to display testimonials with a lightbox effect on the featured image.
[bne_testimonials_list lightbox_rel='lightbox']
Displaying testimonials in a list format with a custom ID for targeting with CSS or JavaScript.
[bne_testimonials_list id='custom-id']
PHP Function Code
In case you have difficulties debugging what causing issues with [bne_testimonials_list]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bne_testimonials_list', 'bne_testimonials_list_shortcode' );
Shortcode PHP function:
function bne_testimonials_list_shortcode( $atts ) {
$atts = shortcode_atts( array(
'post' => '-1', // Number of post
'order' => 'date', // Display Post Order (date / rand / title)
'order_direction' => 'DESC', // Display the order ascending or descending
'name' => 'true', // Post Title
'image' => 'true', // Featured Image
'image_style' => 'square', // Profile image styles ( circle / square / flat-circle / flat-square )
'category' => '', // Category (Taxonomy)
'lightbox_rel' => '', // Allows the use of a lightbox rel command on the featured image.
'class' => '', // Add Custom Class
'id' => ''
), $atts, 'bne_testimonials_list' );
$output = '';
if( current_user_can('edit_pages') ) {
$output .= '<div class="bne-testimonial-warning">Admin Notice (not public): This shortcode was depreciated on June 16, 2017 and will be removed in a future update. Please update this shortcode to use [bne_testimonials layout="list"].</div>';
}
$output .= '<!-- Legacy testimonial shortcode used and migrated to 2x -->';
$output .= do_shortcode('[bne_testimonials layout="list" limit="'.$atts['post'].'" orderby="'.$atts['order'].'" order="'.$atts['order_direction'].'" name="'.$atts['name'].'" image="'.$atts['image'].'" image_style="'.$atts['image_style'].'" category="'.$atts['category'].'" class="'.$atts['class'].'" id="'.$atts['id'].'"]');
return $output;
}
Code file location:
bne-testimonials/bne-testimonials/includes/legacy/migrate.php
BNE Testimonials [bne_testimonials_slider] Shortcode
The bne_testimonials_slider shortcode is a powerful tool for displaying testimonials on your WordPress site. It allows you to customize a variety of features such as the number of posts, order, category, and more. This shortcode also provides control over visual elements like the style of the featured image, navigation options, and animation settings. It even includes an admin notice for deprecated use, ensuring your site stays up-to-date.
Shortcode: [bne_testimonials_slider]
Parameters
Here is a list of all possible bne_testimonials_slider shortcode parameters and attributes:
post
– Determines the number of posts to show.order
– Specifies the order of posts (date, title, or random).order_direction
– Sets the direction of the order (ascending or descending).category
– Defines the specific testimonial category to display.name
– Decides whether to show the post title or not.image
– Decides whether to display the featured image or not.image_style
– Sets the style of the profile image (circle, square, flat-circle, flat-square).lightbox_rel
– Adds a lightbox rel command to the featured image.class
– Adds a custom class to the slider.nav
– Determines whether to show the navigation or not.arrows
– Decides whether to display the navigation arrows or not.pause
– Determines whether to pause on hover or not.animation
– Sets the type of slider animation (slide).animation_speed
– Sets the speed of the animation.smooth
– Determines whether to smoothly transition the height or not.speed
– Sets the speed of the slideshow.
Examples and Usage
Basic example – Displaying testimonials in a slider format with default parameters.
[bne_testimonials_slider]
Advanced examples
Displaying testimonials in a slider format, limiting the number of posts to 5, ordered by date in ascending order, and with circular profile images.
[bne_testimonials_slider post='5' order='date' order_direction='ASC' image_style='circle']
Displaying testimonials in a slider format, from a specific category, with the name and image of the testimonial giver, and with a custom class added to the slider.
[bne_testimonials_slider category='customer-testimonials' name='true' image='true' class='custom-slider']
Displaying testimonials in a slider format, with navigation arrows, pausing on hover, with a slide animation that lasts 700ms, and a slideshow speed of 7000ms.
[bne_testimonials_slider nav='true' arrows='true' pause='true' animation='slide' animation_speed='700' speed='7000']
PHP Function Code
In case you have difficulties debugging what causing issues with [bne_testimonials_slider]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bne_testimonials_slider', 'bne_testimonials_slider_shortcode' );
Shortcode PHP function:
function bne_testimonials_slider_shortcode( $atts ) {
$atts = shortcode_atts( array(
'post' => '-1', // Number of post
'order' => 'date', // Display Post Order (date / rand / title)
'order_direction' => 'DESC', // Display the order ascending or descending
'category' => '', // The Testimonial Category
'name' => 'true', // Post Title
'image' => 'true', // Featured Image
'image_style' => 'square', // Profile image styles ( circle / square / flat-circle / flat-square )
'lightbox_rel' => '', // Allows the use of a lightbox rel command on the featured image.
'class' => '', // Add Custom Class to this particular slider
'nav' => 'true', // Flexslider: controlNav
'arrows' => 'true', // Flexslider: directionNav
'pause' => 'true', // Flexslider: pauseOnHover
'animation' => 'slide', // Flexslider: animation
'animation_speed' => '700', // Flexslider: animationSpeed
'smooth' => 'true', // Flexslider: smoothHeight
'speed' => '7000' // Flexsliser: slideshowSpeed
), $atts, 'bne_testimonials_list' );
$output = '';
if( current_user_can('edit_pages') ) {
$output .= '<div class="bne-testimonial-warning">Admin Notice (not public): This shortcode was depreciated on June 16, 2017 and will be removed in a future update. Please update this shortcode to use [bne_testimonials layout="slider"].</div>';
}
$output .= '<!-- Legacy testimonial shortcode used and migrated to 2x -->';
$output .= do_shortcode('[bne_testimonials layout="slider" limit="'.$atts['post'].'" orderby="'.$atts['order'].'" order="'.$atts['order_direction'].'" name="'.$atts['name'].'" image="'.$atts['image'].'" image_style="'.$atts['image_style'].'" category="'.$atts['category'].'" class="'.$atts['class'].'" nav="'.$atts['nav'].'" arrows="'.$atts['arrows'].'" pause="'.$atts['pause'].'" animation="'.$atts['animation'].'" animation_speed="'.$atts['animation_speed'].'" smooth="'.$atts['smooth'].'" speed="'.$atts['speed'].'"]');
return $output;
}
Code file location:
bne-testimonials/bne-testimonials/includes/legacy/migrate.php
BNE Testimonials [bne_testimonials] Shortcode
The bne-testimonials shortcode is a powerful tool in the BNE Testimonials plugin. It displays testimonials on your site, providing customization options such as layout, theme, image style, and more. The shortcode can pull specific testimonials based on post ID or category. It also offers control over the order of testimonials. Display options include name, image, tagline, and website. For a slider layout, the shortcode provides controls for navigation, pause on hover, animation, and speed. It also allows adding custom CSS classnames to the testimonial wrapper.
Shortcode: [bne_testimonials]
Parameters
Here is a list of all possible bne_testimonials shortcode parameters and attributes:
post
– Number of testimonials to query. Deprecated. Use ‘limit’ instead.limit
– Number of testimonials to display.id
– Testimonial post ID to display.category
– Category of testimonials to display.order
– Order of testimonials. Options: asc or desc.orderby
– Parameter to order testimonials by. Options: name, date, rand, etc.layout
– Layout of testimonials. Options: list, slider.theme
– Theme of testimonials. Options: default, simple.image_style
– Style of the testimonial image. Options: circle, square, flat-circle, flat-square.image_size
– Size of the testimonial image. Any WP crop sizes.name
– Show or hide the testimonial name. Options: true or false.image
– Show or hide the testimonial image. Options: true or false.tagline
– Show or hide the testimonial tagline. Options: true or false.website
– Show or hide the testimonial website. Options: true or false.nav
– Control navigation for Flexslider. Options: true or false.arrows
– Control direction navigation for Flexslider. Options: true or false.pause
– Control pause on hover for Flexslider. Options: true or false.animation
– Animation style for Flexslider. Options: slide.animation_speed
– Animation speed for Flexslider.smooth
– Control smooth height for Flexslider. Options: true or false.speed
– Control slideshow speed for Flexslider.class
– Add custom CSS classnames to the testimonial wrapper.
Examples and Usage
Basic example – Display all testimonials in a list format with the default theme
[bne_testimonials layout='list' theme='default']
Advanced examples
Display testimonials from a specific category, limit the number of testimonials shown to 5, and order them by date in ascending order.
[bne_testimonials category='customer-feedback' limit='5' order='asc' orderby='date']
Display a single testimonial by ID, with the name, image, and tagline hidden, and the website visible.
[bne_testimonials id='123' name='false' image='false' tagline='false' website='true']
Display testimonials in a slider layout with the simple theme, circle image style, and medium image size. The slider will pause on hover, and use a fade animation with an animation speed of 500ms and a slide show speed of 5000ms.
[bne_testimonials layout='slider' theme='simple' image_style='circle' image_size='medium' pause='true' animation='fade' animation_speed='500' speed='5000']
PHP Function Code
In case you have difficulties debugging what causing issues with [bne_testimonials]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( 'bne_testimonials', 'bne_testimonials_shortcode' );
Shortcode PHP function:
function bne_testimonials_shortcode( $atts ) {
$atts = shortcode_atts( array(
/*
* Testimonial Query Arguments
* These control what is pulled from the database.
*
*/
'post' => '', // (depreciated) (-1) Query this numer of testimonials.
'limit' => '-1', // (-1) Query this numer of testimonials. (replaces "post")
'id' => '', // ('') Query only this testimonial post ID.
'category' => '', // ('') Query only this category of testimonials.
'order' => 'desc', // (desc) Direction of testimonials. Options: asc or desc
'orderby' => 'date', // (date) Order of testimonials. Options: name, date, rand, etc
/*
* Display Arguments
* These control structure and style of the testimonials.
*
*/
'layout' => 'list', // (list) Options: list, slider
'theme' => 'default', // (default) Options: default, simple
'image_style' => 'square', // (square) Options: circle, square, flat-circle, flat-square
'image_size' => 'thumbnail', // (thumbnail) Options: Any WP crop sizes
/*
* Theme Content Arguments
* These control what information is displayed within the testimonial.
*
*/
'name' => 'true', // (true) Show/Hide the testimonial name. Options: ture or false
'image' => 'true', // (true) Show/Hide the testimonial image. Options: ture or false
'tagline' => 'true', // (true) Show/Hide the testimonial tagline. Options: ture or false
'website' => 'true', // (true) Show/Hide the testimonial website. Options: ture or false
/*
* Slider Layout Only Arguments
* These control how slider is displayed
*
*/
'nav' => 'true', // (true) Flexslider: controlNav
'arrows' => 'true', // (true) Flexslider: directionNav
'pause' => 'true', // (true) Flexslider: pauseOnHover
'animation' => 'slide', // (slide) Flexslider: animation
'animation_speed' => '700', // (700) Flexslider: animationSpeed
'smooth' => 'true', // (true) Flexslider: smoothHeight
'speed' => '7000', // (7000) Flexsliser: slideshowSpeed
/*
* Other Arguments
*
*/
'class' => '', // ('') Adds custom css classnames to the testimonial wrapper.
), $atts, 'bne_testimonials' );
// Sanitize user inputs
foreach( $atts as $index => $att ) {
$atts[$index] = esc_attr($att);
}
// Taxonomy Query Args
$taxonomy_args = null;
if( $atts['category'] ) {
$taxonomy_args = array(
array(
'taxonomy' => 'bne-testimonials-taxonomy',
'field' => 'slug',
'terms' => explode( ',', esc_html( $atts['category'] ) )
)
);
}
// Backwards compatibility - Replaced "post" with "limit"
if( $atts['post'] ) { $atts['limit'] = $atts['post']; }
// Post Query Args
$query_args = array(
'post_type' => 'bne_testimonials',
'page_id' => $atts['id'],
'order' => $atts['order'],
'orderby' => $atts['orderby'],
'posts_per_page' => $atts['limit'],
// Taxonomy Query
'tax_query' => $taxonomy_args
);
// Single Testimonial Resets
if( $atts['id'] ) {
$atts['layout'] = 'single';
}
// Begin the query
$bne_testimonials_query = new WP_Query( $query_args );
if( $bne_testimonials_query->have_posts() ) {
$wrapper_id = rand(1,1000);
// Category class
$category = ($atts['category']) ? str_replace(',', '-', esc_html( $atts['category'] ) ) : 'all';
$category = sanitize_title_with_dashes( $category );
// Open Wrapper
$output = '<div class="bne-testimonial-wrapper testimonial-wrapper-id-'.$wrapper_id.' testimonial-layout-'.$atts['layout'].' testimonial-theme-'.$atts['theme'].' testimonial-left testimonial-arrangement-1 testimonial-category-'.$category.' '.$atts['class'].' clearfix">';
/*
* Devs - Before Testimonial Filter
*
* Allow devs to extend content before the testimonial.
*
*/
$output .= apply_filters( 'bne_testimonials_before', '' );
/*
* Slider Layout
*
* If using the slider layout, output the
* necessary scripts and structure.
*
*/
if( 'slider' == $atts['layout'] ) {
// Enqueue Flexslider script
wp_enqueue_script( 'flexslider' );
// Assign a random ID each slider instance
$random_id = rand( 1,1000 );
// Init Flexslider
wp_add_inline_script( 'flexslider',
'jQuery(document).ready(function($){
$("#bne-slider-id-'.$random_id.' .bne-testimonial-slider").flexslider({
animation: "'.$atts['animation'].'",
animationSpeed: '.$atts['animation_speed'].',
smoothHeight: '.$atts['smooth'].',
pauseOnHover: '.$atts['pause'].',
controlNav: '.$atts['nav'].',
directionNav: '.$atts['arrows'].',
slideshowSpeed: '.$atts['speed'].'
});
});'
);
// Slider Wrapper
$output .= '<div id="bne-slider-id-'.$random_id.'" class="bne-testimonial-slider-wrapper">';
$output .= '<div class="slides-inner">';
$output .= '<div class="bne-testimonial-slider bne-flexslider">';
$output .= '<ul class="slides">';
// Begin Testimonial Loop!
while( $bne_testimonials_query->have_posts() ) : $bne_testimonials_query->the_post();
$output .= '<li id="testimonial-id-'.get_the_ID().'" class="testimonial-single">';
$output .='<div class="flex-content">';
$output .= bne_testimonials_get_template( 'single', $atts );
$output .= '<div class="clear"></div>';
$output .= '</div>';
$output .= '</li>';
endwhile; // END the Loop!
$output .= '</ul> <!-- .slides (end) -->';
$output .= '</div> <!-- .bne-testimonial-slider (end) -->';
$output .= '</div> <!-- .slides-inner (end) -->';
$output .= '</div> <!-- .bne-testimonial-slider-wrapper (end) -->';
}
/*
* List / Default Layout
*
* If using the list layout or no layout, output the
* necessary structure.
*
*/
else {
// Begin Testimonial Loop!
while( $bne_testimonials_query->have_posts() ) : $bne_testimonials_query->the_post();
$output .= '<div id="testimonial-id-'.get_the_ID().'" class="testimonial-single clearfix">';
$output .= bne_testimonials_get_template( 'single', $atts );
$output .= '<div class="clear"></div>';
$output .= '</div>';
endwhile; // END the Loop!
}
/*
* Devs - After Testimonial Filter
*
* Allow devs to extend content after the testimonial.
*
*/
$output .= apply_filters( 'bne_testimonials_after', '' );
// Close the wrapper!
$output .= '</div><!-- .bne-testimonials-wrapper (end) -->';
} else {
$output = '<div class="bne-testimonial-warning">'.__('No testimonials were found.', 'bne-testimonials').'</div>';
}
// Reset Query and Return output
wp_reset_postdata();
return $output;
}
Code file location:
bne-testimonials/bne-testimonials/includes/shortcode-display.php
Conclusion
Now that you’ve learned how to embed the BNE 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.
Leave a Reply