How to use shortcode attribute in separate function

To be able to use a variable that is essentially being created within the shortcode function, you’ll need to store it somewhere and then retrieve the value. WordPress does use global variables internally to store and carry across values, but I wouldn’t advise you do the same though.

Read about the options API here. Pretty simple functionality.

So something like the following would work within your shortcode function:

update_option('_unique_slider_name', $slider_name);

Then inside of your filter function (or anywhere) you can access the value like this:

$slider_name = get_option('_unique_slider_name');

The value will be cached, so don’t worry about repeated database hits when you try accessing the value.