As Birgire mentioned in the comments, you can hook into the gallery output rather than performing a search/replace on the database.
From the WordPress Codex: Function Reference/shortcode atts gallery
Provides the ability to filter the array returned from shortcode_atts().
You want something like this:
add_filter( 'shortcode_atts_gallery', 'gallery_shortcode_exclude_thumbnail', 10, 3 );
function gallery_shortcode_exclude_thumbnail( $result, $defaults, $atts ) {
if ( empty( $atts['link'] ) ) {
$result['link'] = 'file';
}
return $result;
}
Note: you may want to remove or change the condition empty check, depending on your needs.
Related Posts:
- Need MySQL Query or WP-CLI command to updates old URLs in Shortcodes [closed]
- How navigation works in custom loop within shortcode?
- How Do I Merge Categories With phpMyAdmin
- Update slug (URL) of pending posts via phpMyAdmin
- How to display data from custom table in wordpress phpmyadmin
- Remove shortcodes that are different (but same pattern) in each post
- How to explode single string IF it’s used in shortcode
- Check if CTP category taxonomy is set in shortcode
- Query to list all galleries under a parent post?
- How Do I Delete WordPress Posts Older Than 400 Days, From A WordPress Category
- Running Filter or Shortcode Before Query Prevents Excerpt from Showing
- Why does my shortcode query not working with search term
- Forbidden :You don’t have permission to access /phpmyadmin on this server
- #1045 – Access denied for user ‘root’@’localhost’ (using password: YES)
- MySQL said: Documentation #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)
- Custom shortcode being executed when saving page in wp-admin
- Change appearance of shortcode text inside editor
- Shortcode output always showing at top of page
- How many WordPress SQL Queries per page?
- How to detect if a Shortcode is being called on a page?
- shortcode inside another shortcode
- WordPress gallery ‘post_gallery’ filter doesn’t work with feeds?
- shortcode to create dynamic dropdown box form shortcode attributes
- Ajax not returning anything on form submit
- How do I add my own custom shortcodes?
- Can’t seem to get [shortcode]s to work
- nested Shortcode doesn’t work
- Slow page loading when using a simple shortcode on the same page multiple times
- TinyMCE get selected text and underlying HTML
- Remove and restore one shortcode
- How to delete posts that does not have a thumbnail?
- Rewriting WordPress Gallery Shortcode with Bootstrap Carousel
- Slow meta_query with about 4 milion record on wp_postmeta
- Using do_shortcode with variables?
- Using ACF field in do_shortcode()
- Display content from another site page using a shortcode
- mySQL query. ORDER BY meta_key
- Remove hyperlink on gallery shortcode
- Combining similar shortcode functions?
- Creating a shortcode based on users preferences
- Get a post’s thumbnail url or display default image in shortcode
- Convert HTML Script to Shortcode [closed]
- What is the Correct way to pass parameters in function
- Shortcode – Getting Categories appears on top of website
- How to Modify WordPress Default Image Gallery Shortcode
- Passing html tags as shortcode parameters
- Registration Form Shortcode
- Button Shortcode
- Conditionally Loading JavaScript/CSS for Shortcodes
- Placing tags on wordpress visual editor using shortcodes
- Better ads plugin has 500.000 entries in wp_postmeta
- wpdb COALESCE won’t work
- Changing root password in PHPMyAdmin for WordPress Database when going live
- Inner join overrides Advanced Custom Fields plugin’s get_field [closed]
- Custom SELECT Query With Multiple Meta Values (Ordering Problem)
- how can i pass this attribute in this shortcode?
- How to add a same div on every page
- WordPress Shortcode / Only works in classic editor, gutenberg error / invalid json response
- Display a form partially with a shortcode
- Modifying the wordpress login page and then referencing it with a shortcode problem
- Pass instance number to shortcode child
- Render shortcodes with get_post_custom
- Pass a comma separated shortcode attribute to a function
- get last post’s link with SQL query
- how to write short code in word press
- hard code shortcode only on specific category
- Set redirect for need login
- make user_id in a shortcode dynamic based on who’s logged in
- Shortcode not working in CPT taxonomy
- wp_enqueue_scripts does not work on admin page
- shortcode containing other shortcodes not returning content
- To know whether insert shortcode in custom meta box
- Shortcode not being executed
- Login issue in WordPress
- Load gravity form via ajax using do_shortcode
- How do I point bloginfo(‘stylesheet_directory’) to my parent theme?
- Gallery shortcode is empty but magically creates a gallery
- How to avoid one code multiple times instead do that through some function? Shortcode, but I think shortcode is not used in main theme’s core files?
- Shortcode appeared twice on page, one time before content, one time where it’s really called
- Add a shortcode in woo-function.php
- Get current category and place it in shortcode
- Woocommerce products shortcode specific order
- Modify Blog Module layout in Child theme
- Display title of child pages in shortcode
- Output html source tags inside shortcode
- How can I define the output of shortcode attribute value?
- Using shortcodes that wrap around code
- Shortcode for Admin Theme Option?
- What is the best way to include a template file within a shortcode?
- What makes a placeholder resizable in Tinymce?
- Shortcode templates
- Why My slider shortcode display above header
- Does anyone recognize shortcode ig_special_heading?
- How to scroll to a shortcode-generated anchor
- add post type pram to wp shortcode
- Can I prevent wordpress adding and tags to autoembeds
- Shortcode – Display inline icon before text [closed]
- Working with Shortcode, AJAX, Elementor
- How to exclude some cats from wp_list_categories using shortcut
- How can I create a shortcode that shows a list of categories on the single product page?