When inserting a gallery it adds the following shortcode:
I would like it to automatically add link=”file” as the last attribute, whenever a shortcode is added. Like so:
2 Answers
You can hijack the shortcode handler and set the attribute to a value of your choice. Then call the native callback for this shortcode.
add_shortcode( 'gallery', 'file_gallery_shortcode' );
function file_gallery_shortcode( $atts )
{
$atts['link'] = 'file';
return gallery_shortcode( $atts );
}