Automatically Set Image Hyperlink Functions To None On WordPress

[Normal_Box]WordPress

Set WP Automatic Image Links

WordPress by default links uploaded images to the actual image itself (or file URL), not to the page or post location the image is uploaded to. Meaning, if a visitor were to click on the uploaded image they would be directed to a page with only the image, containing similar permalink structure as: /wp-content/uploads/2012/06/ instead of using the actual page/post ID (or whatever permalink format you use).

This is great for people who use light box setups but can be messy for WordPress users who change or upload many pictures, as they will have to change the image function every time they change or upload a new image.

This WordPress code snippet below will check the value of an image link and then upgrade the image link to none each time you upload an image so you do not have to using the get_option and update_option functions.

[/Normal_Box]

Copy and paste Copy and paste the snippet below into your theme’s functions.php file.

[Normal_Box]

$image_set = get_option( 'image_default_link_type' );
    if (!$image_set == 'none') {
        update_option('image_default_link_type', 'none');
    }

[/Normal_Box]

Sean Doyle

Sean is a distinguished tech author and entrepreneur with over 20 years of extensive experience in cybersecurity, privacy, malware, Google Analytics, online marketing, and various other tech domains. His expertise and contributions to the industry have been recognized in numerous esteemed publications. Sean is widely acclaimed for his sharp intellect and innovative insights, solidifying his reputation as a leading figure in the tech community. His work not only advances the field but also helps businesses and individuals navigate the complexities of the digital world.

4 Responses

  1. Muhid says:

    Excellent stuff, worked it well.

  2. direclapton says:

    Nice post. Well written code nothing to add to it.
    Showing appreciation.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.