{"id":78882,"date":"2012-06-07T12:00:52","date_gmt":"2012-06-07T16:00:52","guid":{"rendered":"http:\/\/wpmu.org\/?p=78882"},"modified":"2012-06-01T11:39:25","modified_gmt":"2012-06-01T15:39:25","slug":"how-to-remove-links-from-wordpress-images","status":"publish","type":"post","link":"https:\/\/wpmudev.com\/blog\/how-to-remove-links-from-wordpress-images\/","title":{"rendered":"How to Automatically Remove Links from WordPress Images"},"content":{"rendered":"<p><a rel=\"lightbox[78882]\" class=\"blog-thumbnail\" href=\"https:\/\/wpmudev.com\/blog\/how-to-remove-links-from-wordpress-images\/broken-link-big\/\" rel=\"attachment wp-att-78883\" target=\"_blank\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-78883\" title=\"broken-link-big\" src=\"https:\/\/wpmudev.com\/blog\/wp-content\/uploads\/2012\/05\/broken-link-big.jpg\" alt=\"Post image\" aria-hidden=\"true\" width=\"647\" height=\"336\" \/><\/a><br \/>\nIn most cases (unless your theme is set up otherwise), you will find that images in a WordPress post are automatically linked to an image file page. Some may like that. Others, however, may not.<\/p>\n<p>If you happen to be one that doesn\u2019t, then there\u2019s a quick and simple fix to this issue. You can place the following code (found at <a href=\"http:\/\/wordpress.stackexchange.com\/questions\/33724\/remove-links-from-images-using-functions-php\" target=\"_blank\">stackexchange<\/a>) in your functions.php file. <strong>(Appearance &gt; Editor &gt; Theme Functions \u2013 functions.php)<\/strong><\/p>\n<pre>add_filter( 'the_content', 'attachment_image_link_remove_filter' );\r\nfunction attachment_image_link_remove_filter( $content ) {\r\n $content =\r\n preg_replace(\r\n array('{&lt;a(.*?)(wp-att|wp-content\\\/uploads)[^&gt;]*&gt;&lt;img}',\r\n '{ wp-image-[0-9]*\" \/&gt;&lt;\/a&gt;}'),\r\n array('&lt;img','\" \/&gt;'),\r\n $content\r\n );\r\n return $content;\r\n }<\/pre>\n<p>And that\u2019s it.<\/p>\n<p>If you would like to make your own simple plugin for this task, you can <a href=\"https:\/\/wpmudev.com\/blog\/how-to-create-your-own-super-simple-wordpress-plugins\/\" target=\"_blank\">learn how to do that here<\/a>.<\/p>\n\n<p>Photo: <a href=\"http:\/\/www.bigstockphoto.com\/image-6256735\/stock-photo-broken-chain\" target=\"_blank\">Broken Chain<\/a> from BigStock<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you\u2019re annoyed that your images are always linked, then automatically unlink them. <\/p>\n","protected":false},"author":84404,"featured_media":78884,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"blog_reading_time":"","wds_primary_category":0,"wds_primary_tutorials_categories":0,"footnotes":""},"categories":[263],"tags":[16],"tutorials_categories":[],"class_list":["post-78882","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-tutorials","tag-images"],"_links":{"self":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/78882","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/users\/84404"}],"replies":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/comments?post=78882"}],"version-history":[{"count":1,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/78882\/revisions"}],"predecessor-version":[{"id":216270,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/posts\/78882\/revisions\/216270"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media\/78884"}],"wp:attachment":[{"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/media?parent=78882"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/categories?post=78882"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tags?post=78882"},{"taxonomy":"tutorials_categories","embeddable":true,"href":"https:\/\/wpmudev.com\/blog\/wp-json\/wp\/v2\/tutorials_categories?post=78882"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}