getting values from a shortcode with an include

I have a checked a few links but nothing seems to for me in getting the attribute value of a shortcode so that I can use it in a condition.

function bf_shortcode_slideshow($atts) {
  extract(shortcode_atts(array(
    'location' => ''
  ), $atts));

  ob_start();
  if  ( $location = 'home' ) {
  classslider = 'homeslider';
}
  include(dirname(dirname(__FILE__)) . '/templates/slideshow.php');
  return ob_get_clean();
}
add_shortcode('rotator', 'bf_shortcode_slideshow');

In the slideshow.php I have a

Read More
echo 'classslider=' . $classslider;

My result for $classslider is blank ( nothing is displayed )
Is there another way you should compare $location to a string value set ?

Related posts

Leave a Reply

1 comment

  1. include changes the scope. You would need to declare $classslider global before defining it, and then use global $classslider; before using it.

    function bf_shortcode_slideshow($atts) {
      global $classslider;
      extract(shortcode_atts(array( ...
    

    I think that will fix your problem.

    I don’t understand why you are using include at all though. There must be a better way to make that slideshow work.