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
- is it possible to get a list of URLs from post_content directly in a mysql query via phpadmin?
- How to log in to phpMyAdmin with WAMP, what is the username and password?
- Setting up foreign keys in phpMyAdmin?
- phpMyAdmin: secret passphrase?
- Forbidden :You don’t have permission to access /phpmyadmin on this server
- ERROR 2002 (HY000): Can’t connect to local MySQL server through socket ‘/var/run/mysqld/mysqld.sock’ (2)
- Fix Access denied for user ‘root’@’localhost’ for phpMyAdmin
- #1045 – Access denied for user ‘root’@’localhost’ (using password: YES)
- MySQL Error #1133 – Can’t find any matching row in the user table
- phpmyadmin #1045 Cannot log in to the MySQL server. after installing mysql command line client
- How to create a foreign key in phpmyadmin
- importing a CSV into phpmyadmin
- MySQL: Can’t create table (errno: 150)
- MySQL: How to reset or change the MySQL root password?
- MySQL Daemon Failed to Start – centos 6
- MySQL said: Documentation #1045 – Access denied for user ‘root’@’localhost’ (using password: NO)
- Moving WordPress from MAMP to WAMP, can’t access pages
- Moving WordPress from MAMP to WAMP, can’t access pages
- convert it into short code & explan how? [closed]
- Enqueue Scripts / Styles when shortcode is present
- Conditionally Loading JavaScript/CSS for Shortcodes
- What does extract( shortcode_atts( array( do?
- What SQL Query to do a simple find and replace
- the_date() not working
- How do I escape a ‘]’ in a short code?
- Pass boolean value in shortcode
- Show shortcode without executing it
- Shortcode always displaying at the top of the page
- Redirect function inside a Shortcode
- How to create a shortcode with 1 parameter (atts)
- how to show the syntax of a shortcode
- Custom shortcode being executed when saving page in wp-admin
- Return only Count from a wp_query request?
- Change appearance of shortcode text inside editor
- current_shortcode() – detect currently used shortcode
- shortcodes output before content [duplicate]
- WordPress plugin shortcode not working
- How to add stylesheets only to pages with specific shortcode?
- Is there a way to list all used/unused WP templates?
- Get Featured Image via direct sql query
- Using get_option() in JavaScript
- Shortcode empty attribute
- How does a shortcode work?
- Shortcode outputs at the top of the_content
- the_excerpt and shortcodes
- Using wp_editor in shortcode
- Remove wpautop from shortcode content / remove whitespace in buffering
- Get current post id witout passing in shortcode
- Why are you using add_action for shortcode?
- How to get URL param to shortcode?
- How to add multiple buttons to TinyMCE?
- Check if post/page has gallery?
- Get first video from the post (both embed and video shortcodes)
- Get shortcode name from within it’s callback function? [duplicate]
- Wordspress add into my javascripts
- Making a Shortcode [NEXT] and [PREVIOUS] to place into specific posts for post navigation
- How do I create a Shortcode that returns text if domain is .com, not .co.uk
- Using preg_replace to separate gallery from the_content?
- simple sql query on wp_postmeta very slow
- Remove specific shortcode from get_the_content()
- How to display the site name in a WordPress page, or post
- Hide/show content starting in the middle of a paragraph
- Combining shortcode and get_template_part
- How can I put a wp_redirect into a shortcode?
- Escaping quotes from shortcode attributes
- Run visual composer code in php page
- short code output too early
- Shortcode in shortcode: How to append variable?
- Remove wptexturize from a shortcode?
- How can i put an array as variable in shortcode_atts?
- Autoembeds don’t work with paragraphs
- Table of Contents with a shortcode
- Create custom [sourcecode] shortcode, the right way?
- TED talks shortcode not working
- Allowing shortcodes inside attributes
- What is the best way to enable nested shortcodes?
- Tinymce – How to hook before or after live shortcodes rendering?
- How to customize a shortcode using the customizer
- Native “playlist” shortcode random playing… How?
- How to Output HTML tags in do_shortcode?
- Optimize Multiple Taxonomy Term MySQL Query?
- List of all inbuilt WordPress shortcodes
- Nested Shortcode Detection
- Shortcode output always showing at top of page
- How many WordPress SQL Queries per page?
- Organizing shortcodes. How to display all of them and their attributes?
- How to detect if a Shortcode is being called on a page?
- How to get current page title inside a page itself in a shortcode and in page content