{"id":581,"date":"2021-10-05T17:28:24","date_gmt":"2021-10-05T11:58:24","guid":{"rendered":"https:\/\/codexcoach.com\/?p=581"},"modified":"2026-06-18T17:28:47","modified_gmt":"2026-06-18T11:58:47","slug":"custom-divi-builder-module","status":"publish","type":"post","link":"https:\/\/codexcoach.com\/custom-divi-builder-module\/","title":{"rendered":"How To Create Custom Divi Builder Module"},"content":{"rendered":"\n<h2>What is the Divi Builder module?<\/h2>\n\n\n\n<p>Web programming languages such as PHP, JavaScript, HTML, CSS, and ReactJS are used to construct custom Divi modules. They are specified by a PHP class that defines all of the options and produces the HTML output of the module on the WordPress front end.<\/p>\n\n\n\n<p>Each module also includes a JavaScript ReactJS component class, which renders the module within the Divi Builder. CSS is used to style elements like effects and margins.<\/p>\n\n\n\n<h2>How to Make a Divi Custom Module?<\/h2>\n\n\n\n<p>Creating a custom Divi module necessitates familiarity with the coding languages PHP, JavaScript, HTML, CSS, and ReactJS.<\/p>\n\n\n\n<p>You must first establish a development environment, then the extension, and finally the module. Let&#8217;s take a quick look at each stage.<\/p>\n\n\n\n<p><strong>Try This Code<\/strong><\/p>\n\n\n\n<p>Easy way to create a Module for Divi Builder. Create the <strong>cxc-divi-module.php<\/strong> file and include it in the functions.php file (this file is located in your theme folder). You can use the below code to include the file <strong>cxc-divi-module.php<\/strong>.<\/p>\n\n\n\n<p>Module settings are defined in the get_fields() method.<\/p>\n\n\n\n<p>include &#8216;<strong>cxc-divi-module.php<\/strong>&#8216;;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-twentytwentyone-border\"><img loading=\"lazy\" width=\"1830\" height=\"843\" src=\"https:\/\/codexcoach.com\/app\/uploads\/2022\/12\/screenshot-webbydemo.in-2022.11.29-17_48_18.png\" alt=\"\" class=\"wp-image-1391\" srcset=\"https:\/\/codexcoach.com\/app\/uploads\/2022\/12\/screenshot-webbydemo.in-2022.11.29-17_48_18.png 1830w, https:\/\/codexcoach.com\/app\/uploads\/2022\/12\/screenshot-webbydemo.in-2022.11.29-17_48_18-300x138.png 300w, https:\/\/codexcoach.com\/app\/uploads\/2022\/12\/screenshot-webbydemo.in-2022.11.29-17_48_18-1024x472.png 1024w, https:\/\/codexcoach.com\/app\/uploads\/2022\/12\/screenshot-webbydemo.in-2022.11.29-17_48_18-768x354.png 768w, https:\/\/codexcoach.com\/app\/uploads\/2022\/12\/screenshot-webbydemo.in-2022.11.29-17_48_18-1536x708.png 1536w, https:\/\/codexcoach.com\/app\/uploads\/2022\/12\/screenshot-webbydemo.in-2022.11.29-17_48_18-1568x722.png 1568w\" sizes=\"(max-width: 1830px) 100vw, 1830px\" \/><\/figure>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-php\" data-file=\"function.php\" data-lang=\"PHP\"><code>&lt;?php\nadd_action( &#39;et_builder_ready&#39;, &#39;cxc_custom_slider_register_modules&#39; );\n\nfunction cxc_custom_slider_register_modules() {\n\n\tif( class_exists( &#39;ET_Builder_Module&#39; ) ) {\n\n\t\tclass Logo_Slider extends ET_Builder_Module {\n\t\t\tfunction init() {\n\t\t\t\t$this-&gt;name       = et_builder_i18n( &#39;Logo Slider&#39; );\n\t\t\t\t$this-&gt;plural     = esc_html__( &#39;Logo Slider&#39;, &#39;et_builder&#39; );\n\t\t\t\t$this-&gt;slug       = &#39;et_pb_logo_slider&#39;;\n\t\t\t\t$this-&gt;vb_support = &#39;on&#39;;\n\t\t\t}\n\n\t\t\tpublic function get_fields() {\n\t\t\t\treturn array(\n\t\t\t\t\t&#39;src&#39;                 =&gt; array(\n\t\t\t\t\t\t&#39;label&#39;              =&gt; et_builder_i18n( &#39;Logo Image&#39; ),\n\t\t\t\t\t\t&#39;type&#39;               =&gt; &#39;upload-gallery&#39;,\n\t\t\t\t\t\t&#39;option_category&#39;    =&gt; &#39;basic_option&#39;,\n\t\t\t\t\t\t&#39;upload_button_text&#39; =&gt; et_builder_i18n( &#39;Upload an image&#39; ),\n\t\t\t\t\t\t&#39;choose_text&#39;        =&gt; esc_attr__( &#39;Choose an Image&#39;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;update_text&#39;        =&gt; esc_attr__( &#39;Set As Image&#39;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;hide_metadata&#39;      =&gt; true,\n\t\t\t\t\t\t&#39;affects&#39;            =&gt; array(\n\t\t\t\t\t\t\t&#39;alt&#39;,\n\t\t\t\t\t\t\t&#39;title_text&#39;,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t&#39;description&#39;        =&gt; esc_html__( &#39;Upload your desired image, or type in the URL to the image you would like to display.&#39;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;toggle_slug&#39;        =&gt; &#39;main_content&#39;,\n\t\t\t\t\t\t&#39;dynamic_content&#39;    =&gt; &#39;image&#39;,\n\t\t\t\t\t\t&#39;mobile_options&#39;     =&gt; true,\n\t\t\t\t\t\t&#39;hover&#39;              =&gt; &#39;tabs&#39;,\n\t\t\t\t\t),\n\t\t\t\t\t\n\t\t\t\t\t&#39;wc_autoplay&#39;            =&gt; array(\n\t\t\t\t\t\t&#39;label&#39;            =&gt; esc_html__( &#39;AutoPlay&#39;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;description&#39;      =&gt; esc_html__( &quot;Disabling AutoPlay will remove the autoplay in slider.&quot;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;type&#39;             =&gt; &#39;yes_no_button&#39;,\n\t\t\t\t\t\t&#39;option_category&#39;  =&gt; &#39;basic_option&#39;,\n\t\t\t\t\t\t&#39;options&#39;          =&gt; array(\n\t\t\t\t\t\t\t&#39;on&#39;  =&gt; et_builder_i18n( &#39;Yes&#39; ),\n\t\t\t\t\t\t\t&#39;off&#39; =&gt; et_builder_i18n( &#39;No&#39; ),\n\t\t\t\t\t\t),\n\t\t\t\t\t\t&#39;default_on_front&#39; =&gt; &#39;on&#39;,\n\t\t\t\t\t\t&#39;toggle_slug&#39;      =&gt; &#39;elements&#39;,\n\t\t\t\t\t\t&#39;affects&#39;          =&gt; array(\n\t\t\t\t\t\t\t&#39;bullet_color&#39;,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t&#39;mobile_options&#39;   =&gt; true,\n\t\t\t\t\t\t&#39;hover&#39;            =&gt; &#39;tabs&#39;,\n\t\t\t\t\t),\n\t\t\t\t\t&#39;wc_loop&#39;            =&gt; array(\n\t\t\t\t\t\t&#39;label&#39;            =&gt; esc_html__( &#39;Loop&#39;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;description&#39;      =&gt; esc_html__( &quot;Disabling Loop will remove the loop in slider.&quot;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;type&#39;             =&gt; &#39;yes_no_button&#39;,\n\t\t\t\t\t\t&#39;option_category&#39;  =&gt; &#39;basic_option&#39;,\n\t\t\t\t\t\t&#39;options&#39;          =&gt; array(\n\t\t\t\t\t\t\t&#39;on&#39;  =&gt; et_builder_i18n( &#39;Yes&#39; ),\n\t\t\t\t\t\t\t&#39;off&#39; =&gt; et_builder_i18n( &#39;No&#39; ),\n\t\t\t\t\t\t),\n\t\t\t\t\t\t&#39;default_on_front&#39; =&gt; &#39;on&#39;,\n\t\t\t\t\t\t&#39;toggle_slug&#39;      =&gt; &#39;elements&#39;,\n\t\t\t\t\t\t&#39;affects&#39;          =&gt; array(\n\t\t\t\t\t\t\t&#39;bullet_color&#39;,\n\t\t\t\t\t\t),\n\t\t\t\t\t\t&#39;mobile_options&#39;   =&gt; true,\n\t\t\t\t\t\t&#39;hover&#39;            =&gt; &#39;tabs&#39;,\n\t\t\t\t\t),\n\t\t\t\t\t&#39;time_duration&#39; =&gt; array(\n\t\t\t\t\t\t&#39;label&#39;           =&gt; esc_html__( &#39;Time Duration&#39;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;type&#39;            =&gt; &#39;text&#39;,\n\t\t\t\t\t\t&#39;option_category&#39; =&gt; &#39;basic_option&#39;,\n\t\t\t\t\t\t&#39;description&#39;     =&gt; esc_html__( &#39;Enter Time Duration.&#39;, &#39;et_builder&#39; ),\n\t\t\t\t\t\t&#39;toggle_slug&#39;     =&gt; &#39;main_content&#39;,\n\t\t\t\t\t),\t\t\t\t\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpublic function render( $unprocessed_props, $content = null, $render_slug ) {\n\t\t\t\tob_start();\n\t\t\t\t$attachment_ids = $this-&gt;props[&#39;src&#39;];\n\t\t\t\t$time_duration = $this-&gt;props[&#39;time_duration&#39;];\n\n\t\t\t\tif( !empty( $time_duration ) ){\n\t\t\t\t\t$time_duration = $time_duration;\n\t\t\t\t}else{\n\t\t\t\t\t$time_duration = &#39;5000&#39;;\n\t\t\t\t}\n\n\t\t\t\t$autoplay = $this-&gt;props[&#39;wc_autoplay&#39;];\n\t\t\t\tif($autoplay == &#39;on&#39;){\n\t\t\t\t\t$autoplay = &#39;true&#39;;\n\t\t\t\t}else{\n\t\t\t\t\t$autoplay = &#39;false&#39;;\n\t\t\t\t}\n\n\t\t\t\t$loop = $this-&gt;props[&#39;wc_loop&#39;];\n\t\t\t\tif( $loop == &#39;on&#39; ){\n\t\t\t\t\t$loop = &#39;true&#39;;\n\t\t\t\t}else{\n\t\t\t\t\t$loop = &#39;false&#39;;\n\t\t\t\t}\n\n\t\t\t\t$logo_cust_id = rand(1111111,9999999);\n\n\t\t\t\tif( !empty( $attachment_ids ) ){\n\t\t\t\t\t$attachment_ids = explode( &quot;,&quot;, $attachment_ids );\n\t\t\t\t\tif( $attachment_ids ){\n\t\t\t\t\t\t?&gt;\n\t\t\t\t\t\t&lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/OwlCarousel2\/2.3.4\/assets\/owl.carousel.min.css&quot; integrity=&quot;sha512-tS3S5qG0BlhnQROyJXvNjeEM4UpMXHrQfTGmbQ1gKmelCxlSEBUaxhRBj\/EFTzpbP4RVSrpEikbmdJobCvhE3g==&quot; crossorigin=&quot;anonymous&quot; referrerpolicy=&quot;no-referrer&quot; \/&gt;\n\t\t\t\t\t\t&lt;link rel=&quot;stylesheet&quot; href=&quot;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/OwlCarousel2\/2.3.4\/assets\/owl.theme.default.min.css&quot; integrity=&quot;sha512-sMXtMNL1zRzolHYKEujM2AqCLUR9F2C4\/05cdbxjjLSRvMQIciEPCQZo++nk7go3BtSuK9kfa\/s+a4f4i5pLkw==&quot; crossorigin=&quot;anonymous&quot; referrerpolicy=&quot;no-referrer&quot; \/&gt;\n\t\t\t\t\t\t&lt;div id=&quot;logo-slider-&lt;?php echo $logo_cust_id; ?&gt;&quot; class=&quot;owl-carousel owl-theme&quot;&gt;\n\t\t\t\t\t\t\t&lt;?php\n\t\t\t\t\t\t\tforeach($attachment_ids as $attachment_id){\n\t\t\t\t\t\t\t\t?&gt;\n\t\t\t\t\t\t\t\t&lt;div class=&quot;item1&quot;&gt;\n\t\t\t\t\t\t\t\t\t&lt;img width=&quot;180&quot; height=&quot;80&quot; src=&quot;&lt;?php echo wp_get_attachment_url( $attachment_id );?&gt;&quot;&gt;\n\t\t\t\t\t\t\t\t&lt;\/div&gt;\n\t\t\t\t\t\t\t&lt;?php } \n\t\t\t\t\t\t\t?&gt;\n\t\t\t\t\t\t&lt;\/div&gt;\t\t\t\t\n\t\t\t\t\t\t&lt;script src=&quot;https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/OwlCarousel2\/2.3.4\/owl.carousel.min.js&quot; integrity=&quot;sha512-bPs7Ae6pVvhOSiIcyUClR7\/q2OAsRiovw4vAkX+zJbw3ShAeeqezq50RIIcIURq7Oa20rW2n2q+fyXBNcU9lrw==&quot; crossorigin=&quot;anonymous&quot; referrerpolicy=&quot;no-referrer&quot;&gt;&lt;\/script&gt;\n\t\t\t\t\t\t&lt;script&gt;\n\t\t\t\t\t\t\tjQuery(document).ready(function($){\n\t\t\t\t\t\t\t\t$(&#39;#logo-slider-&lt;?php echo $logo_cust_id; ?&gt;&#39;).owlCarousel({\n\t\t\t\t\t\t\t\t\tloop: &lt;?php echo $loop; ?&gt;,\n\t\t\t\t\t\t\t\t\tmargin: 30,\n\t\t\t\t\t\t\t\t\tautoplay:&lt;?php echo $autoplay; ?&gt;,\n\t\t\t\t\t\t\t\t\tautoplayTimeout:&lt;?php echo $time_duration; ?&gt;,\n\t\t\t\t\t\t\t\t\tnav:true,\n\t\t\t\t\t\t\t\t\tdots: false,\n\t\t\t\t\t\t\t\t\tresponsiveClass: true,\n\t\t\t\t\t\t\t\t\tresponsive: {\n\t\t\t\t\t\t\t\t\t\t0: {\n\t\t\t\t\t\t\t\t\t\t\titems: 1,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t600: {\n\t\t\t\t\t\t\t\t\t\t\titems: 3,\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t1000: {\n\t\t\t\t\t\t\t\t\t\t\titems: 5,\n\t\t\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t&lt;\/script&gt;\n\t\t\t\t\t\t&lt;?php\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\treturn ob_get_clean();\n\t\t\t}\n\t\t}\n\t\tnew Logo_Slider;\n\t}\n}\n?&gt;<\/code><\/pre><\/div>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>Divi Builder is now a wiser WordPress page builder tool than it was before, thanks to additional features like more modules, a front-end visual editor, and more layouts.<\/p>\n\n\n\n<p>There are over 30 content modules to pick from, as well as a plethora of fantastic configurable page layouts. Divi Builder is a truly versatile tool that allows users to create any type of website with WordPress.<\/p>\n<div id=\"ezoic-pub-ad-placeholder-118\"><\/div>","protected":false},"excerpt":{"rendered":"<p>What is the Divi Builder module? Web programming languages such as PHP, JavaScript, HTML, CSS, and ReactJS are used to construct custom Divi modules. They are specified by a PHP class that defines all of the options and produces the HTML output of the module on the WordPress front end. Each module also includes a [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":15771,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_aib_schema_json_ld":""},"categories":[7,10],"tags":[],"_links":{"self":[{"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/posts\/581"}],"collection":[{"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/comments?post=581"}],"version-history":[{"count":7,"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/posts\/581\/revisions"}],"predecessor-version":[{"id":1447,"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/posts\/581\/revisions\/1447"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/media\/15771"}],"wp:attachment":[{"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/media?parent=581"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/categories?post=581"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codexcoach.com\/wp-json\/wp\/v2\/tags?post=581"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}