Removing Image Links in WordPress

Removing Image Links in WordPress

20740285426_ecd82cc362_zBy default WordPress adds a link to images you upload and place in posts and pages.  The link just goes to a page that shows the image.  This behavior is undesirable for two reasons.

First, it is unexpected behavior.  Users expect links to take them somewhere useful and most of the time a page with just the image on it may not be what they were expecting.  This confuses users and, if they aren’t computer-savvy, they may leave your site altogether if they can’t figure out how to get back to the page they were reading.

Second, it may hurt your SEO ranking by adding unfruitful links to your page weight.  In some cases the search engine may return the image page instead of your post in a search result!

While you can choose what to link to when you upload new images, what is the solution for the oodles of images you’ve already uploaded?

WPBeginner has a quick, easy solution.  First, log into your WordPress admin and then click on Appearance->Editor.  There will be a list of files on the right side.  Look for functions.php and click on it.  It will load in the central edit box.  Copy and paste the following code at the end of all other code, but before any final ?> tag.

function wpb_imagelink_setup() {
	$image_set = get_option( 'image_default_link_type' );
	if ($image_set !== 'none') {
		update_option('image_default_link_type', 'none');
add_action('admin_init', 'wpb_imagelink_setup', 10);

Click on “Update File” and your images will not longer have links!

Warning: Some themes don’t allow you to make changes to the functions.php file.  If you don’t see the functions.php file in the right-hand list under Appearances->Editor, or if you can’t access the Editor at all, then you will need to manually change the functions.php file.  Depending on your expertise you may need professional assistance (like me).

Additionally, if you update your theme you will need to add this change back.  Ideally if you want to hack your theme like this you would set up a child theme.  But that is a topic for another post!

Follow me

Submit a Comment