{"id":3794,"date":"2014-04-19T20:03:02","date_gmt":"2014-04-19T20:03:02","guid":{"rendered":"http:\/\/www.dognmonkey.com\/techs\/?p=3794"},"modified":"2014-04-19T20:03:02","modified_gmt":"2014-04-19T20:03:02","slug":"replace-a-string-with-new-string-for-all-posts-in-wordpress","status":"publish","type":"post","link":"https:\/\/www.dognmonkey.com\/mythemes\/replace-a-string-with-new-string-for-all-posts-in-wordpress.html","title":{"rendered":"Replace A String With New String For All Posts In WordPress"},"content":{"rendered":"<p style=\"text-align: center;\"><em>Now WordPress is at version 3.9 and the new theme &#8220;Twenty Fourteen&#8221; is supposed to be the best free theme ever, but the theme does kill 2 of my plug-ins Mediabox Advanced and FancyBox 1.3.4. So, if I want to use Twenty Fourteen after I&#8217;m done modifying it, I have to replace the class strings of FancyBox with stings of FancyBox 2 and Mediabox Advanced with Slimbox 2.0.5 or ShadowBox.<\/em><\/p>\n<p style=\"text-align: center;\"><i>FancyBox 1.3.4 I used &#8216;class=&#8221;ib&#8221;&#8216; for iFrames and FancyBox 2 &#8216;class=&#8221;ib2 fancybox.iframe&#8221; &#8211; To replace all posts that are using &#8216;class=&#8221;ib&#8221;&#8216; I need to edit the function.php of the &#8220;twenty fourteen&#8221; theme and add a function like this. This function will replace all posts with &#8216;class=&#8221;ib&#8221;&#8216; with &#8216;class=&#8221;ib2 fancybox.iframe&#8221;&#8216;.<\/i><\/p>\n<div class=\"igallery\">\n<p style=\"text-align: center;\"><a class=\"preview\" href=\"https:\/\/www.dognmonkey.com\/mythemes\/wp-content\/uploads\/fancyboxstring.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-3795\" src=\"\/\/www.dognmonkey.com\/techs\/wp-content\/uploads\/2014\/04\/fancyboxstring-300x43.png\" alt=\"fancyboxstring\" width=\"300\" height=\"43\" srcset=\"https:\/\/www.dognmonkey.com\/mythemes\/wp-content\/uploads\/fancyboxstring-300x43.png 300w, https:\/\/www.dognmonkey.com\/mythemes\/wp-content\/uploads\/fancyboxstring.png 566w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<\/div>\n<blockquote>\n<p class=\"p1\"><span class=\"s1\">function<\/span> replace_fancybox_to_fancybox2($content) {<\/p>\n<p class=\"p2\"><span class=\"s2\">\u00a0 \u00a0 \u00a0 \u00a0<\/span><span class=\"s1\">return<\/span><span class=\"s2\"> str_replace(<\/span>&#8216;class=&#8221;ib&#8221;&#8216;<span class=\"s2\">, <\/span>&#8216;class=&#8221;ib2 fancybox.iframe&#8221;&#8216;<span class=\"s2\">, $content);<\/span><\/p>\n<p class=\"p1\">\u00a0 \u00a0 }<\/p>\n<p class=\"p2\"><span class=\"s2\">add_filter(<\/span>&#8216;the_content&#8217;<span class=\"s2\">, <\/span>&#8216;replace_fancybox_to_fancybox2&#8217;<span class=\"s2\">);<\/span><\/p>\n<\/blockquote>\n<p class=\"p2\">One more way<\/p>\n<blockquote>\n<p class=\"p2\">function replace_ib($content)<br \/>\n{<br \/>\n$content = str_replace(&#8216;class=&#8221;ib&#8221;&#8216;, &#8216;class=&#8221;ib2 fancybox.iframe&#8221;&#8216;,$content);<br \/>\nreturn $content;<br \/>\n}<br \/>\nadd_filter(&#8216;the_content&#8217;,&#8217;replace_ib&#8217;);<\/p>\n<\/blockquote>\n<p class=\"p2\"><ul class=\"lcp_catlist\" id=\"lcp_instance_0\"><\/ul><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Now WordPress is at version 3.9 and the new theme &#8220;Twenty Fourteen&#8221; is supposed to be the best free theme ever, but the theme does kill 2 of my plug-ins Mediabox Advanced and FancyBox 1.3.4. So, if I want to use Twenty Fourteen after I&#8217;m done modifying it, I have to replace the class strings <a href=\"https:\/\/www.dognmonkey.com\/mythemes\/replace-a-string-with-new-string-for-all-posts-in-wordpress.html\" class=\"more-link\">&#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[77,54],"tags":[424,426,468,990,1154],"class_list":["post-3794","post","type-post","status-publish","format-standard","hentry","category-themes","category-wordpress","tag-fancybox-1-3-4","tag-fancybox-2","tag-function-php","tag-replace-strings","tag-twenty-fourteen"],"views":4,"_links":{"self":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/posts\/3794","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/comments?post=3794"}],"version-history":[{"count":0,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/posts\/3794\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/media?parent=3794"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/categories?post=3794"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dognmonkey.com\/mythemes\/wp-json\/wp\/v2\/tags?post=3794"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}