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.
Related Posts:
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- How to get shortcode’s input values inside a filter?
- Filter specific shortcode output?
- Insert new element to array with add_filter
- Insert Custom HTML After Shortcode
- Is there a way to add another row to the tinyMCE kitchen sink toggle?
- add_filter and changing output captions of image gallery
- How to add attribute to output with wp_video_shortcode add_filter
- Search content for shortcodes and get parameters
- Change default settings used by gallery shortcode
- Shortcodes not resolved in AJAX call response
- Ajax, filters and shortcodes
- Format content value from DB outside of WordPress filters
- Use content custom filter for all shortcodes
- How to link current user to their author page through shortcodes
- filter title from shortcode
- how to remove filter from wordpress shortcode output
- Error when overriding only some audio shortcode HTML output
- Using wp_handle_upload() to Direct Specific Path by Using $overrides
- Shortcodes — Using add_action, add_filter in the shortcode
- Make an array filterable per hook
- How to pass variables to custom filter from multiple functions
- How to filter backend post list showing only posts having a shortcode
- Redirect to another page using contact form 7? [closed]
- How can I return shortcode output to the top of the content?
- the_excerpt filter doesn’t work as expected
- Trying to get property of non-object in shortocde
- run shortcode in excerpt of single custom post type
- Filter everything from content except output of a shortcode
- Something is filtering my shortcodes… Can’t figure out what
- How to use do_shortcode_tag to modify the output of a shortcode?
- Shortcodes within the sidebar text/html widget: How to preserve the raw HTML output of the shortcode?
- How to change dynamically page title according to variable data?
- How can I filter tag_description()?
- WordPress removing slashes from shortcode output
- How to remove shortcode(s) from WYSIWYG Page editor for Non Admins
- Shortcode / plugin with custom (flexible) output
- Filter Shortcodes when using get_page
- Parse a shortcode differently based on on what it’s nested in
- Need to return shortcode text instead of the output
- add_filter to the_content after apply_filters
- post_orderby filter breaks function
- Counting a WP_Post Object value in an arary, using a filter?
- the_content getting current page content instead specified ID
- Override wordpress audio playlist
- How to wrap pattern-matches from the_content in [wiki]-shortcode tags
- Add Index to Item in WordPress Gallery
- create a shortcode with acf including a filter
- How to take shortcode and content separately from a page?
- Auto-generated excerpt with shortcode and read more button/text link
- Take filter from multiple functions
- shortcode function outputs multiple anchor tags
- apply_filters to $GLOBALS
- Change shortcode output (filter?)
- Is it possible to include the add_filter() function within a shortcode function
- Activate short codes for all post queries?
- Problem with shortcodes in external file
- How can I display wp_link_pages before a shortcode, if it is used, or display after content?
- posts_results filter – additional sort, with a meta value, to move posts to the end of the results, with pagination working
- Add custom options to the wplink dialog
- How many filter/action hooks are healthy?
- How can I extend the Gutenberg table block transform to allow colspans/rowspans on pasted table elements?
- get_option() filtering and getting out of recursion
- Get excerpt from $post->post_content
- How can I add information underneath the user’s name on the users.php page?
- Is calling function_exists() faster or slower that apply_filters()
- Filtered query_vars becomes global. Why does this work?
- How can I filter Microsoft Word gunk from pasted content?
- Shortcode from a widget is wrapped in unwanted element
- How to disable all WordPress emails modularly and programatically?
- Allow Profile HTML for select users
- Alter only the page title, not the post titles within
- Load different template file when condition met?
- WordPress 3.5+ upload tool filter
- Search with filters and title
- Filter all html output
- How can override a add_filter of a plugin?
- Return array of images after content
- failed to filter hook `get_terms_defaults`
- Nested calls the the_content filter
- How to change domain used when pinging sites
- Filter list by a unique meta value dilemma
- Overwrite default WordPress wording
- WooCommerce Variable Product Price – Where is “From” text generated from?
- Using ‘posts_where’ on a query with a custom field
- Wrap h1-h6 in a div
- add filter login_redirect does not contain original requested redirect
- How to add numeric slug for child page in WordPress 5.9?
- Custom Login Errors and variables I can use
- How to order by taxonomy using wp_query
- ‘the_content’ filter removing html tags from post content
- Feed, RSS not able to clear the cache and cannot change the limit of cache life time
- WP action/filter to modify title before header output and article output?
- WP Filter to change the URL of an Anchor wrapping the last gallery image
- Gutenberg – Add align controls to a custom block
- Add a specific part of current category page url to shortcode
- To add a custom filter based on a meta field
- I can not include page to wordpress function add_filter, the_content
- Add default user field to WooCommerce checkout [closed]
- Filter to shorten column content on edit-tags.php