Untested (and can’t test right now) but you ought to be able to add attributes with a filter… something like:
function test_sc($atts,$content) {
// echo 'test_sc';
$atts = shortcode_atts(
array(
'foo' => 'no foo',
'bar' => 'default bar',
),
$atts,
'testsc'
);
// var_dump($atts);
}
add_shortcode('testsc','test_sc');
function test_shortcode_att_add($atts) {
# this filter should only run once (first use on page)
remove_filter('shortcode_atts_testsc','test_shortcode_att_add');
$atts['xxx'] = 'yyy';
return $atts;
}
add_filter('shortcode_atts_testsc','test_shortcode_att_add');
Of course, I don’t know exactly what you attribute you are trying to add, or what kind of supporting code it might depend on.
Related Posts:
- Conditionally Loading JavaScript/CSS for Shortcodes
- Pass boolean value in shortcode
- Escaping quotes from shortcode attributes
- How to add ‘class’ attribute into shortcode [audio]?
- Automatically add this attribute to the gallery shortcode
- How to handle valueless attributes in shortcodes?
- Get multiple shortcode attribute values
- wpautop() when shortcode attributes are on new lines break args array
- Remove width and height attributes from [gallery] output
- Add attribute to existing Shortcode
- Shortcode displays only default attribute values
- Extending Shortcode attributes
- Remove HTML content if attribute is not set / variable attributes
- Global, network-wide shortcodes or text replace functions
- getting values from a shortcode with an include
- Why are Shortcodes Disabled in Widgets by Default?
- Replace / Remove Shortcode after 1st run / post
- Caption shortcodes not including caption as attribute
- Conditionally Loading JavaScript/CSS for Shortcodes
- Check if CTP category taxonomy is set in shortcode
- Passing variable in nested shortcodes
- How to use a nested shortcode to render the value of an attribute in parent shortcode
- Which wordpress function is the caption shortcode linked to?
- How to process a single attribute in a SQL request twice times?
- shortcode atts not working
- Second attribute of shortcode is not changing why?
- Replace custom gallery shortcode with default gallery shortcode
- Shortcode Attribute contains clone of all shortcode attributes
- How can I define the output of shortcode attribute value?
- Remove width and height attributes from [gallery] output
- Using get_option() in JavaScript
- Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation
- How to display the site name in a WordPress page, or post
- How can I put a wp_redirect into a shortcode?
- Native “playlist” shortcode random playing… How?
- Why do_shortcode is not executing the shortcode in data-* html attributes?
- Is shortcode_unautop() broken?
- Some doubts about gallery shortcode in WordPress
- has_shortcode for content added after the content
- How can I make a shortcode from this code?
- Adding PHP/HTML code inside page from custom template
- WordPress auto adds p to shortcode parameters
- ShortCode and extra
- List monthy archives for specific year with wp_get_archives
- Call Shortcode inside another Shortcodes callback
- Creating a shortcode in a plugin that includes JS
- Shortcode to delete post from front end
- MathJax inside shortcode
- How to parse shortcodes within returned content
- Shortcodes attributes defaults
- Get Required Assets (JS, CSS etc) for post using REST API
- shortcode in snippet plugin not work
- AJAX and Shortcode with Parameters
- Best place for short bio,image and button [closed]
- How to protect parts of my code from TinyMCE modification when switching from text to visual mode?
- Shortcode output appearing at the top of the page only [duplicate]
- problem with shortcodes nesting
- OOP and WordPress shortcode
- PHP/WordPress — How do I check if Shortcode returns content?
- Convert my php code into shortcode
- Add shortcode with open close function
- Shortcode is not working
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Why can’t I display attachment_image_src with Custom Size?
- Shortcode Strategy
- Enclosing Shortcode is acting like self-closing
- Shortcode into the same shortcode
- Execute shortcodes in PHP
- A shortcode nested inside a shortcode
- Custom Shortcode + Querying and Ordering Posts using multiple Advanced Custom checkboxes
- call other shortcode in the email contactform7 send [closed]
- Putting a space between the buttons [closed]
- Dynamic number within shortcode
- How can i strip shortcode from HTML title tag?
- Returning HTML to Shortcode Block
- WP REST API remove the WordPress shortcodes from the JSON wp/v2/posts content->rendered
- How to display html element and php string in the same line?
- Hide download option video shortcode
- WordPress Shorcode Display hierarchical taxonomy [child, parent]
- Shortcode not working in Jetpack Top Posts & Pages widget
- Restricting shortcode for users
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- Gutenberg running code only available in front end within shortcode
- Insert HTML in content property and render it using shortcodes
- Redirect per shortcode if user is logged in
- Shortcode, vs blocks, vs templates – what would you do for choosing or creating custom post data in editor?
- Convert WordPress shortcodes into plain html
- How to make a shortcode with a line break in it parse correctly?
- Plugin Shortcode value in post
- Woocommerce Filter Main Loop by Tag [closed]
- Shortcodes: override a shortcode / change shortcode on the fly
- Separating Custom Template logic
- woocommerce Product shortcode create [closed]
- A number appears inside a div called wpb_wrapper, when I use a custom shortcode
- Enclose article’s body with default shortcode
- Why is my ajax live search not working when i use a shortcode to call it?
- WordPress functions.php shortcode is not working [closed]
- My first WordPress shortcode just returning []
- WordPress shortcode select option not working [closed]
- How to use multiple values in “Shortcode”? [closed]