The shortcode_atts_{$shortcode} filter allows default parameters to be modified for shortcodes.
To modify the shortcode, we’ll use the shortcode_atts_gallery filter.
Here is an example that changes the defaults for the columns and link parameters in the shortcode. Note that if the user specifies values for these parameters, those values will be used; we’re just changing the defaults.
add_filter( 'shortcode_atts_gallery', 'wpse246345_shortcode_atts_gallery', 10, 4 );
function wpse246345_shortcode_atts_gallery( $out, $pairs, $atts, $shortcode ) {
if ( ! isset( $atts['columns'] ) ) {
$out['columns'] = 5;
}
if ( ! isset( $atts['link'] ) ) {
$out['link'] = 'file';
}
return $out;
}
Related Posts:
- add_filter and changing output captions of image gallery
- Ajax, filters and shortcodes
- Add Index to Item in WordPress Gallery
- apply_filters(‘the_content’, $content) vs do_shortcode($content)
- How to get shortcode’s input values inside a filter?
- Filter specific shortcode output?
- Insert Custom HTML After Shortcode
- Is there a way to add another row to the tinyMCE kitchen sink toggle?
- Using variable from one filter in another filter
- How to add attribute to output with wp_video_shortcode add_filter
- Search content for shortcodes and get parameters
- Shortcodes not resolved in AJAX call response
- Format content value from DB outside of WordPress filters
- How to filter ‘post_gallery’ after all other filters/plugins etc
- 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
- How to use shortcode attribute in separate function
- How do I filter title and alt attributes in the gallery shortcode?
- WP Filter to change the URL of an Anchor wrapping the last gallery image
- Shortcodes — Using add_action, add_filter in the shortcode
- How to pass variables to custom filter from multiple functions
- How to filter backend post list showing only posts having a shortcode
- Add Lightbox To WordPress Native Gallery
- add img class to native wordpress galleries
- How to display the content HTML of a page without displaying the gallery code as well
- How can I return shortcode output to the top of the content?
- Is it possible to override the default Gallery Settings form?
- get_post() containing gallery is outputting an unmatched closing div at the end of the content
- the_excerpt filter doesn’t work as expected
- 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?
- Native gallery custom html output
- How can I filter tag_description()?
- WordPress removing slashes from shortcode output
- Get_template_part inside filter?
- custom gallery filter with image caption as link title?
- How to remove shortcode(s) from WYSIWYG Page editor for Non Admins
- Gallery stripped from excerpt of post
- 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
- Hooked into wp_get_attachment_caption to add content to the default description; not working for jetpack slideshow. Why?
- 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
- create a shortcode with acf including a filter
- How to take shortcode and content separately from a page?
- How to stop echoing gallery inside content?
- Auto-generated excerpt with shortcode and read more button/text link
- 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?
- Upload restrictions – upload_mimes – filter: Adding multiple MIMEs for a single extension and adding multiple extensions for a single MIME type?
- How can I change the email that is inside the default email texts of wordpress?
- Conditional does not work with add_filter
- Modify message displayed on post save
- Pass debug_backtrace() in WordPress filter
- I need to hook and change language of facebook sdk
- change “missing attachment” text functions.php
- Use has_filter on comment_post
- Shorten the title length
- Problem with Class, Filters and Callbacks
- Renaming wordpress login and get new password button
- How to redirect template_directory to subdomain relativ url?
- How do I add tags to entire comments, not just their text
- add_filter( ‘the_title’ gets through this if statement twice
- Changing the category for existing Gutenberg blocks
- Modify WordPress Page Title ()
- How to add lazy field in content endpoint using Gutenberg blocks
- how to use apply filter for Class?
- Reload page with a different shortcode when a user selects from a dropdown
- How can I see exactly what arguments are being passed through a filter so that I may modify them?
- Re-order search results with posts_orderby filter and post meta value
- Set Microsoft Word links to open in new window/tab
- WordPress get_avatar filter to match logins
- ‘the_content’ Filter delivers empty string with lengh (608)
- Output dynamic_sidebar_params in wp_head
- How to sort posts according to meta value?
- Remove width and height attributes from [gallery] output
- Updating User Profile on Registration
- remove_filter excerpt_more from a plugin class
- Why does using excerpt_more filter change link location?
- Hooking/Filtering theme name to add theme directory
- How to use filter in this situation, can not modify the structure using filter
- add_filter – create_function pb in PHP8
- Woocommerce price filter widget always shows max price of most expensive product in the whole shop