Change WordPress default image link

When images are added to a WordPress site through the “Add Media” button, they will default to linking to themselves. Learn how you can change the default behavior for images by reading this article.


Add the following code to your functions.php file.


The update_option function modifies the database and only needs to be run one time for the change to take effect. If you’re planning on leaving the code in your functions file, you can use the code below. It’s a little more efficient and won’t be called as many times as the one shown above.

function modify_media_link($value) {
	$media_default = get_option('image_default_link_type');
	if ($media_default !== $value) {
		update_option('image_default_link_type', $value);
add_action('admin_init', modify_media_link('post'));