Skip to content

Instantly share code, notes, and snippets.

@versluis
Created August 14, 2019 13:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save versluis/baf0c710c56dea6e0a42ea892fee1338 to your computer and use it in GitHub Desktop.
Save versluis/baf0c710c56dea6e0a42ea892fee1338 to your computer and use it in GitHub Desktop.
make Gutenberg Galleries link to Media File by default
// make galleries link to Media File
// https://wordpress.stackexchange.com/questions/115368/overide-gallery-default-link-to-settings
function make_galleries_link_to_file() {
$post_type_object = get_post_type_object( 'post' );
$post_type_object->template = array(
array( 'core/gallery', array(
'linkTo' => 'media',
) ),
);
}
add_action( 'init', 'make_galleries_link_to_file' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment