Knowledgebase

The Divi Code Module

The Divi Code Module

How to add, configure and customize the Divi code module.

 

The Code Module is a blank canvas that allows you to add code to your page, such as plugin shortcodes or static HTML. If you would like to use a third party plugin, for example a third party slider plugin, you can simply place the plugin’s shortcode into a standard or fullwidth code module to display the item unimpeded.

How To Add A Code Module To Your Page

Before you can add a code module to your page, you will first need to jump into the Divi Builder. Once the Divi Theme has been installed on your website, you will notice a Use Divi Builder button above the post editor every time you are building a new page. Clicking this button will enable the Divi Builder, giving you access to all of the Divi Builder’s modules. Next, click the Use Visual Builder button to launch the builder in Visual Mode. You can also click the Use Visual Builder button when browsing your website on the front end if you are logged in to your WordPress Dashboard.

code module

Once you have entered the Visual Builder, you can click the gray plus button to add a new module to your page. New modules can only be added inside of Rows. If you are starting a new page, don’t forget to add a row to your page first. We have some great tutorials about how to use Divi’s row and section elements.

code module

Locate the code module within the list of modules and click it to add it to your page. The module list is searchable, which means you can also type the word “code” and then click enter to automatically find and add the code module! Once the module has been added, you will be greeted with the module’s list of options. These options are separated into three main groups: ContentDesign and Advanced.

Use Case Example: Adding an External Style Sheet to Animate Content on an Individual Page

In this example, I’m going to add a link script to import Animate.css in order to add animation effects to the elements on the page. Since the Animate.css file has a lot of code, it makes sense to load it only on the page that I need it.

Simply add a Regular Section and a fullwidth (1 column) row and add the Code Module.

code module

In the content text box, add the code snippet.

code module

Now, all you have to do is add a few CSS classes to animate any element of your page of CSS classes to your page. In this example, I’m going to make the button bounce when loading the page.

In the Button Module Settings, under the Advanced tab, enter the two clases “animated” and “bounce” into the CSS Class text box.

code module

Now the button will bounce when loading the page.

code module

Here are a few more examples of how you can use the code module:

  1. Add javascript code blocks or libraries that you only what applied to your page.
  2. Integrate third party plugins like the revolution slider.
  3. You can use the Fullwidth Code Module to embed a Typeform for more interactive questionnaires, contact forms, etc…
  4. Add a floating action menu
  5. Create a slide-in top bar ad.
  6. Add a floating action button.

Tip: Sometimes adding code with line breaks will cause the code not to work. It is best to create your code in a text editor and concat it (make it all on one line) before pasting it in the Code Module.

Code Content Options

Within the content tab you will find all of the module’s content elements, such as text, images and icons. Anything that controls what appears in your module will always be found within this tab.

code module

Content

Here you can place any HTML, CSS or JavaScript code that you would like to display on the page in the current location. Only Editors and Admins are allowed to post unfiltered HTML, which means some code may be stripped from the module if it is used by an Author or Contributor. You can also placed shortcodes into the module. These shortcodes will be rendered inside of the parent column without any additional Divi module wrappers.

Admin Label

This will change the label of the module in the builder for easy identification. When using WireFrame view in the Visual Builder, these labels will appear within the module block in the Divi Builder interface.

Code Design Options

Within the design tab you will find all of the module’s styling options, such as fonts, colors, sizing and spacing. This is the tab you will use to change how your module looks. Every Divi module has a long list of design settings that you can use to change just about anything.

code module

Max Width

Any value entered here will restrict the width of any content rendered within the code module to the defined value. For example, entering 50% into the input field will reduce the content of the code module to 50% of the column that contains it.

Code Advanced Options

Within the advanced tab, you will find options that more experienced web designers might find useful, such as custom CSS and HTML attributes. Here you can apply custom CSS to any of the module’s many elements. You can also apply custom CSS classes and IDs to the module, which can be used to customize the module within your child theme’s style.css file.

code module

CSS ID

Enter an optional CSS ID to be used for this module. An ID can be used to create custom CSS styling, or to create links to particular sections of your page.

CSS Class

Enter optional CSS classes to be used for this module. A CSS class can be used to create custom CSS styling. You can add multiple classes, separated with a space. These classes can be used in your Divi Child Theme or within the Custom CSS that you add to your page or your website using the Divi Theme Options or Divi Builder Page Settings.

Custom CSS

Custom CSS can also be applied to the module and any of the module’s internal elements. Within the Custom CSS section, you will find a text field where you can add custom CSS directly to each element. CSS input into these settings are already wrapped within style tags, so you need only enter CSS rules separated by semicolons.

Visibility

This option lets you control which devices your module appears on. You can choose to disable your module on tablets, smart phones or desktop computers individually. This is useful if you want to use different modules on different devices, or if you want to simplify the mobile design by eliminating certain elements from the page.

  • The Divi Code Module How to add, configure and customize the Divi code module.
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The Divi Video Slider Module

The Divi Video Slider Module How to add, configure and customize the Divi video slider module....

The Divi Video Module

The Divi Video Module How to add, configure and customize the Divi video module.     Adding...

The Divi Toggle Module

The Divi Toggle Module How to add, configure and customize the Divi toggle module. Toggles...

The Divi Text Module

The Divi Text Module How to add, configure and customize the Divi text module.     Text can...

The Divi Testimonial Module

The Divi Testimonial Module How to add, configure and customize the Divi testimonials module....