Below, you’ll find a detailed guide on how to add the Serious Slider 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 Serious Slider Plugin shortcode not to show or not to work correctly.
Before starting, here is an overview of the Serious Slider Plugin and the shortcodes it provides:
Serious Slider is a highly versatile WordPress plugin. It effortlessly allows you to create stunning, responsive image and content sliders to enhance your site's visual appeal.
- [cryout-serious-slider]
Serious Slider [cryout-serious-slider] Shortcode
The Cryout Serious Slider shortcode is used to render a customizable slideshow on your WordPress website. It pulls images, captions, and links from a specified slider ID, then displays them in a sequence. The shortcode allows for various customization options like sorting order, hiding captions, and adjusting responsiveness. It also includes styling options for different themes.
Shortcode: [cryout-serious-slider]
Parameters
Here is a list of all possible cryout-serious-slider shortcode parameters and attributes:
id
– Specifies the unique ID of the slider.count
– Determines the number of slides to display.hidetitle
– If set, hides the title of the slide.hidecaption
– If set, hides the caption of the slide.orderby
– Sets the order of the slides based on different parameters.
Examples and Usage
Basic example – Displaying a slider using its ID
[cryout_serious_slider id=1 /]
Advanced examples
Displaying a slider with a specified count of slides, hiding the title, and setting the sorting order to random.
[cryout_serious_slider id=1 count=5 hidetitle=true sort='rand' /]
Displaying a slider with a specified count of slides, hiding the caption, and setting the sorting order by publish date.
[cryout_serious_slider id=1 count=5 hidecaption=true sort='date' /]
Displaying a slider with a specified count of slides, hiding the title, and setting the sorting order by menu order.
[cryout_serious_slider id=1 count=5 hidetitle=true sort='order' /]
PHP Function Code
In case you have difficulties debugging what causing issues with [cryout-serious-slider]
shortcode, check below the related PHP functions code.
Shortcode line:
add_shortcode( $this->shortcode_tag, array( $this, 'shortcode_render' ) );
Shortcode PHP function:
function shortcode_render($attr) {
global $cryout_serious_slider;
// exit silently if slider is is not defined
if ( empty($attr['id'])) { return; }
$options = apply_filters('cryout_serious_slider_shortcode_attributes', $this->shortcode_options( $attr['id'] ), $attr, $attr['id']);
extract($options);
if (!empty($attr['count'])) $count = esc_attr($attr['count']); else $count = -1;
$hidetitle = ( !empty($hidetitles) || !empty($attr['hidetitle']) );
$hidecaption = !empty($attr['hidecaption']);
switch ($sort) {
case 'order':
// sort by order param
$orderby = 'menu_order';
$order = 'ASC';
break;
case 'rand':
// sort by order param
$orderby = 'rand';
$order = 'ASC';
break;
default:
// sort by publish date (default)
$orderby = 'date';
$order = 'DESC';
break;
} // switch
// allow order override via shortcode
if (!empty($attr['orderby'])) $orderby = esc_attr($attr['orderby']);
$slider_classes = array();
$slider_classes[] = 'seriousslider-overlay' . $overlay;
$slider_classes[] = 'seriousslider-' . $theme;
$slider_classes[] = 'seriousslider-shadow-' . $shadow;
$slider_classes[] = 'seriousslider-responsive-' . $responsiveness;
$slider_classes[] = 'seriousslider-hidetitles-' . $hidetitles;
$slider_classes[] = 'seriousslider-' . $animation;
$slider_classes[] = 'seriousslider-sizing' . $sizing;
$slider_classes[] = 'seriousslider-align' . $align;
$slider_classes[] = 'seriousslider-caption-animation-' . $captionanimation;
$slider_classes[] = 'seriousslider-textstyle-' . $textstyle;
$slider_classes = implode(' ', $slider_classes);
$cid = abs($attr['id']).'-rnd'.rand(1000,9999);
$the_query = new WP_Query(
array(
'post_type' => array( $cryout_serious_slider->posttype ),
'order' => $order,
'orderby' => $orderby,
'showposts' => $count,
'tax_query' => array(
array(
'taxonomy' => $cryout_serious_slider->taxonomy,
'field' => 'id',
'terms' => array( $cid ),
),
),
)
);
$counter = 0;
$this->id = $attr['id'];
$this->cid = $cid;
ob_start(); ?>
.serious-slider-<?php echo $cid ?> { max-width: <?php echo intval( $width ); ?>px; }
.serious-slider-<?php echo $cid ?>.seriousslider-sizing1, .serious-slider-<?php echo $cid ?>.seriousslider-sizing1 img { max-height: <?php echo intval( $height ); ?>px; }
.serious-slider-<?php echo $cid ?>.seriousslider-sizing2, .serious-slider-<?php echo $cid ?>.seriousslider-sizing2 img.item-image { height: <?php echo intval( $height ); ?>px; }
.serious-slider-<?php echo $cid ?> .seriousslider-caption-inside { max-width: <?php echo intval($caption_width) ?>px; font-size: <?php echo round($textsize,2) ?>em; }
.serious-slider-<?php echo $cid ?> .seriousslider-inner > .item {
-webkit-transition-duration: <?php echo round($transition/1000,2) ?>s;
-o-transition-duration: <?php echo round($transition/1000,2) ?>s;
transition-duration: <?php echo round($transition/1000,2) ?>s; }
.seriousslider-textstyle-bgcolor .seriousslider-caption-title span {
background-color: rgba( <?php echo $this->sanitizer->hex2rgb( $accent ); ?>, 0.6);
}
/* Indicators */
.seriousslider-dark .seriousslider-indicators li.active,
.seriousslider-square .seriousslider-indicators li.active,
.seriousslider-tall .seriousslider-indicators li.active,
.seriousslider-captionleft .seriousslider-indicators li.active,
.seriousslider-captionbottom .seriousslider-indicators li.active {
background-color: rgba( <?php echo $this->sanitizer->hex2rgb( $accent ); ?>, 0.8);
}
/* Arrows */
.seriousslider-dark .seriousslider-control:hover .control-arrow,
.seriousslider-square .seriousslider-control:hover .control-arrow,
.seriousslider-tall .seriousslider-control .control-arrow {
background-color: rgba( <?php echo $this->sanitizer->hex2rgb( $accent ); ?>, 0.8);
}
.seriousslider-tall .seriousslider-control:hover .control-arrow {
color: rgba( <?php echo $this->sanitizer->hex2rgb( $accent ); ?>, 1);
background-color: #FFF;
}
.seriousslider-captionbottom .seriousslider-control .control-arrow,
.seriousslider-captionleft .seriousslider-control .control-arrow {
color: rgba( <?php echo $this->sanitizer->hex2rgb( $accent ); ?>, .8);
}
.seriousslider-captionleft .seriousslider-control:hover .control-arrow {
color: rgba( <?php echo $this->sanitizer->hex2rgb( $accent ); ?>, 1);
}
/* Buttons */
<?php switch ($theme) {
case 'light': ?>
/* Light */
.seriousslider-light .seriousslider-caption-buttons a:nth-child(2n+1),
.seriousslider-light .seriousslider-caption-buttons a:hover:nth-child(2n) {
color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
.seriousslider-light .seriousslider-caption-buttons a:hover:nth-child(2n+1) {
background-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
border-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
<?php break;
case 'dark': ?>
/* Dark */
.seriousslider-dark .seriousslider-caption-buttons a:nth-child(2n) {
color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
.seriousslider-dark .seriousslider-caption-buttons a:hover:nth-child(2n+1) {
border-color: #FFF;
}
.seriousslider-dark .seriousslider-caption-buttons a:hover:nth-child(2n) {
border-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
.seriousslider-dark .seriousslider-caption-buttons a:nth-child(2n+1) {
background-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
border-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
<?php break;
case 'square': ?>
/* Square */
.seriousslider-square .seriousslider-caption-buttons a:nth-child(2n+1) {
background-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
.seriousslider-square .seriousslider-caption-buttons a:nth-child(2n) {
background: #fff;
color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
.seriousslider-square .seriousslider-caption-buttons a:hover:nth-child(2n+1) {
color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
background: #FFF;
}
.seriousslider-square .seriousslider-caption-buttons a:hover:nth-child(2n) {
color: #fff;
background-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
<?php break;
case 'tall': ?>
/* Tall */
.seriousslider-tall .seriousslider-caption-buttons a:nth-child(2n+1) {
background-color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
.seriousslider-tall .seriousslider-caption-buttons a:nth-child(2n) {
background: #FFF;
color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
.seriousslider-tall .seriousslider-caption-buttons a:hover {
opacity: 0.8;
}
<?php break;
case 'captionleft': ?>
/* Left caption */
.seriousslider-captionleft .seriousslider-caption-buttons a:hover {
color: <?php echo $this->sanitizer->color_clean( $accent ); ?>;
}
<?php
break;
default:
break;
} // switch($theme)
$this->custom_style[] = ob_get_clean();
add_action( 'wp_footer', array($this, 'shortcode_style') );
ob_start() ?>
var interval = <?php echo $delay ?>/200;
jQuery(document).ready(function(){
jQuery('#serious-slider-<?php echo $cid ?>').carousel({
interval: <?php if ($autoplay) echo $delay; else echo 'false'; ?>,
pause: '<?php echo $hover ?>',
stransition: <?php echo $transition ?>
});
});
<?php
$this->custom_script[] = ob_get_clean();
add_action( 'wp_footer', array($this, 'shortcode_script') );
if ( $the_query->have_posts() ):
ob_start(); ?>
<div id="serious-slider-<?php echo $cid ?>" class="cryout-serious-slider seriousslider serious-slider-<?php echo $cid ?> cryout-serious-slider-<?php echo $attr['id'] ?> <?php echo $slider_classes ?>" data-ride="seriousslider">
<div class="seriousslider-inner" role="listbox">
<?php while ($the_query->have_posts()):
$the_query->the_post();
$counter++;
// retrieve parameters
$slide_meta = get_post_meta( get_the_ID() );
if ( !empty($slide_meta['cryout_serious_slider_link'][0]) )
$meta_link = ' href="' . esc_url($slide_meta['cryout_serious_slider_link'][0]) . '"';
else $meta_link = '';
if ( !empty($slide_meta['cryout_serious_slider_target'][0]) && $slide_meta['cryout_serious_slider_target'][0] )
$meta_target = 'target="_blank"';
else $meta_target = '';
for ( $i=1; $i<=$this->butts; $i++ ) {
if ( !empty($slide_meta['cryout_serious_slider_button'.$i][0]) )
${'meta_button'.$i} = $slide_meta['cryout_serious_slider_button'.$i][0]; else ${'meta_button'.$i} = FALSE;
if ( !empty($slide_meta['cryout_serious_slider_button'.$i.'_url'][0]) )
${'meta_button'.$i.'_url'} = $slide_meta['cryout_serious_slider_button'.$i.'_url'][0]; else ${'meta_button'.$i.'_url'} = '';
if ( !empty($slide_meta['cryout_serious_slider_button'.$i.'_target'][0]) && $slide_meta['cryout_serious_slider_button'.$i.'_target'][0] )
${'meta_button'.$i.'_target'} = 'target="_blank"'; else ${'meta_button'.$i.'_target'} = '';
}
$image_data = wp_get_attachment_image_src (get_post_thumbnail_ID( get_the_ID() ), 'full' );
if ( !empty($sizing) && $sizing ) $sizes = 'width="' . $width . '" height="' . $height . '"'; else $sizes = '';
$slide_title = get_the_title();
$slide_text = get_the_content();
?>
<div class="item slide-<?php echo $counter ?> <?php if ($counter==1) echo 'active' ?>" role="option">
<?php if (!empty($image_data[0])): ?>
<a <?php echo $meta_link; ?> <?php echo $meta_target; ?>>
<img class="item-image" src="<?php echo $image_data[0] ?>" alt="<?php the_title_attribute(); ?>" <?php echo $sizes ?>>
</a>
<?php endif; ?>
<?php if (( !empty($slide_title) || !empty($slide_text) ) && !$hidecaption): ?>
<div class="seriousslider-caption">
<div class="seriousslider-caption-inside">
<?php if (!empty($slide_title) && !$hidetitle) { ?><div class="seriousslider-caption-title"><span><?php the_title(); ?></span></div><?php } ?>
<?php if (!empty($slide_text)) { ?><div class="seriousslider-caption-text"><?php the_content() ?></div><?php } ?>
<div class="seriousslider-caption-buttons">
<?php for ( $i=1; $i<=$this->butts; $i++ ) { ?>
<?php if ( !empty(${'meta_button'.$i}) ) { ?>
<a class="seriousslider-button" href="<?php echo esc_url( ${'meta_button'.$i.'_url'}) ?>" <?php echo ${'meta_button'.$i.'_target'} ?>><?php echo esc_attr( ${'meta_button'.$i} ) ?></a>
<?php } ?>
<?php } ?>
</div>
</div><!--seriousslider-caption-inside-->
</div><!--seriousslider-caption-->
<?php endif; ?>
<div class="seriousslider-hloader"></div>
<figure class="seriousslider-cloader">
<svg width="200" height="200">
<circle cx="95" cy="95" r="20" transform="rotate(-90, 95, 95)"/>
</svg>
</figure>
</div>
<?php endwhile; ?>
</div>
<div class="seriousslider-indicators">
<ol class="seriousslider-indicators-inside">
<?php for ($i=0;$i<$counter;$i++) { ?>
<li data-target="#serious-slider-<?php echo $cid ?>" data-slide-to="<?php echo $i?>" <?php if ($i==0) echo 'class="active"' ?>></li>
<?php } ?>
</ol>
</div>
<button class="left seriousslider-control" data-target="#serious-slider-<?php echo $cid ?>" role="button" data-slide="prev">
<span class="sicon-prev control-arrow" aria-hidden="true"></span>
<span class="sr-only"><?php _e('Previous Slide','cryout-serious-slider') ?></span>
</button>
<button class="right seriousslider-control" data-target="#serious-slider-<?php echo $cid; ?>" role="button" data-slide="next">
<span class="sicon-next control-arrow" aria-hidden="true"></span>
<span class="sr-only"><?php _e('Next Slide','cryout-serious-slider') ?></span>
</button>
</div>
<?php
wp_reset_query(); /* clean up the query */
return ob_get_clean();
endif; ?>
<!-- end cryout serious slider -->
<?php
}
Code file location:
cryout-serious-slider/cryout-serious-slider/inc/shortcodes.php
Conclusion
Now that you’ve learned how to embed the Serious Slider 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.
Leave a Reply