{"id":181,"date":"2016-07-13T12:20:00","date_gmt":"2016-07-13T12:20:00","guid":{"rendered":"http:\/\/www.3pixls.com\/blog\/?p=181"},"modified":"2016-07-13T13:22:15","modified_gmt":"2016-07-13T13:22:15","slug":"how-to-remove-p-tag-from-around-images-in-the_content","status":"publish","type":"post","link":"https:\/\/www.3pixls.com\/blog\/how-to-remove-p-tag-from-around-images-in-the_content\/","title":{"rendered":"How to Remove p tag from around images in the_content"},"content":{"rendered":"<p>Adding this snippet to the &#8220;functions.php&#8221; of your wordpress theme will remove the HTML p tag from around images in the_content.<br \/>\n[php]<br \/>\nfunction filter_ptags_on_images($content){<br \/>\n    return preg_replace(&#8216;\/&lt;p&gt;\\s*(&lt;a .*&gt;)?\\s*(&lt;img .* \\\/&gt;)\\s*(&lt;\\\/a&gt;)?\\s*&lt;\\\/p&gt;\/iU&#8217;, &#8216;\\1\\2\\3&#8217;, $content);<br \/>\n}<br \/>\nadd_filter(&#8216;the_content&#8217;, &#8216;filter_ptags_on_images&#8217;);<br \/>\n[\/php]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Adding this snippet to the &#8220;functions.php&#8221; of your wordpress theme will remove the HTML p tag from around images in the_content. [php] function filter_ptags_on_images($content){ return preg_replace(&#8216;\/&lt;p&gt;\\s*(&lt;a .*&gt;)?\\s*(&lt;img .* \\\/&gt;)\\s*(&lt;\\\/a&gt;)?\\s*&lt;\\\/p&gt;\/iU&#8217;, &#8216;\\1\\2\\3&#8217;, $content); } add_filter(&#8216;the_content&#8217;, &#8216;filter_ptags_on_images&#8217;); [\/php]<\/p>\n","protected":false},"author":1,"featured_media":183,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[9],"tags":[],"_links":{"self":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts\/181"}],"collection":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/comments?post=181"}],"version-history":[{"count":1,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts\/181\/revisions"}],"predecessor-version":[{"id":182,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/posts\/181\/revisions\/182"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/media\/183"}],"wp:attachment":[{"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/media?parent=181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/categories?post=181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.3pixls.com\/blog\/wp-json\/wp\/v2\/tags?post=181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}