{"id":24380,"date":"2021-03-05T11:29:39","date_gmt":"2021-03-05T10:29:39","guid":{"rendered":"https:\/\/www.markhendriksen.com\/?p=24380"},"modified":"2021-03-05T11:29:40","modified_gmt":"2021-03-05T10:29:40","slug":"can-you-add-php-code-to-the-divi-code-module","status":"publish","type":"post","link":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/","title":{"rendered":"Can You Add PHP Code To The Divi Code Module?"},"content":{"rendered":"\n<p>There are times that you need to add some PHP code to Divi. Perhaps you found a PHP snippet with a certain function and you need to place that PHP code in Divi.<\/p>\n\n\n\n<p>Divi comes with a code module but unfortunately, you can not add PHP code to the Divi code module. You can only add CSS, HTML, and Javascript to the code module. However, there are different ways to add PHP code to Divi.<\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-0e17e0a9 gb-headline-text\">Add PHP Code In The Functions.php File<\/h2>\n\n\n\n<p>You can add PHP code in Divi&#8217;s functions.php file. this file is usually located in \/wp-content\/themes\/Divi\/functions.php. Or in WordPress, you can navigate to Appearance &gt; Theme Editor and from the dropdown (right-top) you can choose function.php.<\/p>\n\n\n\n<p>There is one huge disadvantage to placing your PHP code directly in the themes function.php file. After a Divi update, this file will be overwritten and you will lose all the changes you made here.<\/p>\n\n\n\n<p>To prevent this you can&nbsp;<a target=\"_blank\" href=\"https:\/\/www.markhendriksen.com\/divi-child-theme-essential-guide\/\" rel=\"noreferrer noopener\">create a Divi child theme<\/a>&nbsp;and place your PHP in that functions.php file. This way when Divi is updated you will not lose your changes.<\/p>\n\n\n\n<h2 class=\"gb-headline gb-headline-440616fe gb-headline-text\">Use a Plugin To Add PHP Code<\/h2>\n\n\n\n<p>Another easy way to add PHP code to Divi is by using this free&nbsp;<a target=\"_blank\" href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" rel=\"noreferrer noopener\">Code Snippets<\/a>&nbsp;plugin. After installing this plugin navigate to Snippets &gt; Add New<\/p>\n\n\n\n<p>Give your code snippet a title and in the code field, you can place your PHP code.<\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"680\" height=\"337\" src=\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Code-snippets-plugin.jpg\" alt=\"Code Snippets plugin\" class=\"wp-image-24382\" srcset=\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Code-snippets-plugin.jpg 680w, https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Code-snippets-plugin-380x188.jpg 380w, https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Code-snippets-plugin-300x149.jpg 300w, https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Code-snippets-plugin-510x253.jpg 510w, https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Code-snippets-plugin-121x60.jpg 121w, https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Code-snippets-plugin-182x90.jpg 182w\" sizes=\"(max-width: 680px) 100vw, 680px\" \/><\/figure><\/div>\n\n\n\n<p>So you can not use the Divi code module for PHP but there are still good methods to add PHP code to your website.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There are times that you need to add some PHP code to Divi. Perhaps you found a PHP snippet with a certain function and you need to place that PHP code in Divi. Divi comes with a code module but unfortunately, you can not add PHP code to the Divi code module. You can only [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":24384,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29],"tags":[],"class_list":["post-24380","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-divi-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.1.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Can You Add PHP Code To The Divi Code Module?<\/title>\n<meta name=\"description\" content=\"Is it possible to add PHP code to the Divi code Module? No, but you can use this free plugin to place PHP code in Divi.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Can You Add PHP Code To The Divi Code Module?\" \/>\n<meta property=\"og:description\" content=\"Is it possible to add PHP code to the Divi code Module? No, but you can use this free plugin to place PHP code in Divi.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/\" \/>\n<meta property=\"og:site_name\" content=\"Mark Hendriksen\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/madebymarkhendriksen\" \/>\n<meta property=\"article:published_time\" content=\"2021-03-05T10:29:39+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-03-05T10:29:40+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"720\" \/>\n\t<meta property=\"og:image:height\" content=\"400\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Mark Hendriksen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Mark Hendriksen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/\"},\"author\":{\"name\":\"Mark Hendriksen\",\"@id\":\"https:\/\/www.markhendriksen.com\/#\/schema\/person\/d40c4ac37512479c71b48ad2879fb765\"},\"headline\":\"Can You Add PHP Code To The Divi Code Module?\",\"datePublished\":\"2021-03-05T10:29:39+00:00\",\"dateModified\":\"2021-03-05T10:29:40+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/\"},\"wordCount\":282,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.markhendriksen.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg\",\"articleSection\":[\"Divi tutorials\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/\",\"url\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/\",\"name\":\"Can You Add PHP Code To The Divi Code Module?\",\"isPartOf\":{\"@id\":\"https:\/\/www.markhendriksen.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg\",\"datePublished\":\"2021-03-05T10:29:39+00:00\",\"dateModified\":\"2021-03-05T10:29:40+00:00\",\"description\":\"Is it possible to add PHP code to the Divi code Module? No, but you can use this free plugin to place PHP code in Divi.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage\",\"url\":\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg\",\"contentUrl\":\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg\",\"width\":720,\"height\":400,\"caption\":\"Can you add PHP code in the Divi code module\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.markhendriksen.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Divi tutorials\",\"item\":\"https:\/\/www.markhendriksen.com\/divi-tutorials\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Can You Add PHP Code To The Divi Code Module?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.markhendriksen.com\/#website\",\"url\":\"https:\/\/www.markhendriksen.com\/\",\"name\":\"Mark Hendriksen\",\"description\":\"\",\"publisher\":{\"@id\":\"https:\/\/www.markhendriksen.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.markhendriksen.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.markhendriksen.com\/#organization\",\"name\":\"Mark Hendriksen\",\"url\":\"https:\/\/www.markhendriksen.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.markhendriksen.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/01\/Mark-Hendriksen-Logo.png\",\"contentUrl\":\"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/01\/Mark-Hendriksen-Logo.png\",\"width\":354,\"height\":40,\"caption\":\"Mark Hendriksen\"},\"image\":{\"@id\":\"https:\/\/www.markhendriksen.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/madebymarkhendriksen\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.markhendriksen.com\/#\/schema\/person\/d40c4ac37512479c71b48ad2879fb765\",\"name\":\"Mark Hendriksen\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.markhendriksen.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/1416c89ed4da57b902960a21b7fa25cb91558d39eff48c8b5017bd4c9bcc59a9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/1416c89ed4da57b902960a21b7fa25cb91558d39eff48c8b5017bd4c9bcc59a9?s=96&d=mm&r=g\",\"caption\":\"Mark Hendriksen\"},\"url\":\"https:\/\/www.markhendriksen.com\/author\/twopixels\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Can You Add PHP Code To The Divi Code Module?","description":"Is it possible to add PHP code to the Divi code Module? No, but you can use this free plugin to place PHP code in Divi.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/","og_locale":"en_US","og_type":"article","og_title":"Can You Add PHP Code To The Divi Code Module?","og_description":"Is it possible to add PHP code to the Divi code Module? No, but you can use this free plugin to place PHP code in Divi.","og_url":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/","og_site_name":"Mark Hendriksen","article_publisher":"https:\/\/www.facebook.com\/madebymarkhendriksen","article_published_time":"2021-03-05T10:29:39+00:00","article_modified_time":"2021-03-05T10:29:40+00:00","og_image":[{"width":720,"height":400,"url":"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg","type":"image\/jpeg"}],"author":"Mark Hendriksen","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Mark Hendriksen","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#article","isPartOf":{"@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/"},"author":{"name":"Mark Hendriksen","@id":"https:\/\/www.markhendriksen.com\/#\/schema\/person\/d40c4ac37512479c71b48ad2879fb765"},"headline":"Can You Add PHP Code To The Divi Code Module?","datePublished":"2021-03-05T10:29:39+00:00","dateModified":"2021-03-05T10:29:40+00:00","mainEntityOfPage":{"@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/"},"wordCount":282,"commentCount":0,"publisher":{"@id":"https:\/\/www.markhendriksen.com\/#organization"},"image":{"@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage"},"thumbnailUrl":"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg","articleSection":["Divi tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/","url":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/","name":"Can You Add PHP Code To The Divi Code Module?","isPartOf":{"@id":"https:\/\/www.markhendriksen.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage"},"image":{"@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage"},"thumbnailUrl":"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg","datePublished":"2021-03-05T10:29:39+00:00","dateModified":"2021-03-05T10:29:40+00:00","description":"Is it possible to add PHP code to the Divi code Module? No, but you can use this free plugin to place PHP code in Divi.","breadcrumb":{"@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#primaryimage","url":"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg","contentUrl":"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/03\/Can-you-add-PHP-code-in-the-Divi-code-module.jpg","width":720,"height":400,"caption":"Can you add PHP code in the Divi code module"},{"@type":"BreadcrumbList","@id":"https:\/\/www.markhendriksen.com\/can-you-add-php-code-to-the-divi-code-module\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.markhendriksen.com\/"},{"@type":"ListItem","position":2,"name":"Divi tutorials","item":"https:\/\/www.markhendriksen.com\/divi-tutorials\/"},{"@type":"ListItem","position":3,"name":"Can You Add PHP Code To The Divi Code Module?"}]},{"@type":"WebSite","@id":"https:\/\/www.markhendriksen.com\/#website","url":"https:\/\/www.markhendriksen.com\/","name":"Mark Hendriksen","description":"","publisher":{"@id":"https:\/\/www.markhendriksen.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.markhendriksen.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.markhendriksen.com\/#organization","name":"Mark Hendriksen","url":"https:\/\/www.markhendriksen.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.markhendriksen.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/01\/Mark-Hendriksen-Logo.png","contentUrl":"https:\/\/www.markhendriksen.com\/wp-content\/uploads\/2021\/01\/Mark-Hendriksen-Logo.png","width":354,"height":40,"caption":"Mark Hendriksen"},"image":{"@id":"https:\/\/www.markhendriksen.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/madebymarkhendriksen"]},{"@type":"Person","@id":"https:\/\/www.markhendriksen.com\/#\/schema\/person\/d40c4ac37512479c71b48ad2879fb765","name":"Mark Hendriksen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.markhendriksen.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/1416c89ed4da57b902960a21b7fa25cb91558d39eff48c8b5017bd4c9bcc59a9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/1416c89ed4da57b902960a21b7fa25cb91558d39eff48c8b5017bd4c9bcc59a9?s=96&d=mm&r=g","caption":"Mark Hendriksen"},"url":"https:\/\/www.markhendriksen.com\/author\/twopixels\/"}]}},"_links":{"self":[{"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/posts\/24380","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/comments?post=24380"}],"version-history":[{"count":2,"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/posts\/24380\/revisions"}],"predecessor-version":[{"id":24383,"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/posts\/24380\/revisions\/24383"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/media\/24384"}],"wp:attachment":[{"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/media?parent=24380"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/categories?post=24380"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.markhendriksen.com\/wp-json\/wp\/v2\/tags?post=24380"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}