Hey Divi Nation! I’m back with another pen to share with you all that will add a Floating Action Menu to your Divi website. I’m going to show you two different ways to implement it on your site. The first is taking advantage of Divi’s Code Module, something I’m hoping to encourage more of this year, and the second is using Divi’s Theme Options.
Let’s get into it!
How to Add a Floating Action Menu to a Divi Post or Page with the Code Module
Here is how to add the above pen into a single post or page of your Divi website:
Fist, make sure you have created a free codepen.io account and logged in. It takes less than a minute and you’re up and running. So don’t worry, it’s painless. Once you’re logged in on your own account navigate to the pen I’ve created for this tutorial, the floating action menu.
Press “command + s” to save the pen under your own account. You should see the name change under “a pen by” in the top left corner, to your name. Now that you’ve copied the pen to your account you can edit it.
In the html panel, start by locating this line of code:
<img alt="Andy Tran" src="https://en.gravatar.com/userimage/64217327/096c4ecedf5cf0259c707b7f5255246d.jpg?size=400" />
Editing this line will change the profile image. Change the alt text to your name and change the src link to your own Gravatar image. You can also use the image link of a photo you’ve uploaded to your WordPress website by navigating to your media library, editing the photo, and then copying that image’s link into the src space indicated above.
Next we’re going to change the name next to the profile image by editing this line of html:
<h2 class="at-floating-navigation__title">Andy Tran</h2>
Simply swap out “Andy Tran” for your own name.
Next, we’re going to change the link for the text, “view profile” by changing the link in this line of code:
<a href="https://andytran.me">View Profile</a>
Once that is complete we can move on to changing the links for the menu items Settings, Help Desk, and Log Out.
<a class="at-floating-navigation__item" href="https://andytran.me">Settings</a> <a class="at-floating-navigation__item" href="https://andytran.me">Help Desk</a> <a class="at-floating-navigation__item" href="https://andytran.me">Log Out</a>
For that matter, you can also change the menu items themselves by changing the words “Settings”, “Help Desk”, and “Log Out” to whatever you want.
When all of your edits have been made, hit “command + s” again to save. Then copy the page url and head over to the codepen generator I created to compile this code into a single easily paste-able block of code.
Paste the url into the url field there and click the blue “Generate” button. Right away you’ll see the code block below and the blue button will now say “Copy Code”. Click the blue button again to copy the code block to your clipboard.
We’re now ready to add the action menu we’ve created to our desired Divi post or page. Add a code module to the post or page you’d like your floating action menu to appear on. It doesn’t matter where the code module is located.
Open up the code module and paste in the code you’ve copied from the codepen generator. Save changes and update the post or page when complete.
Then, go ahead and check out the result!
How to Add a Floating Action Menu Site Wide
If you would like your new floating action menu to appear across your entire site instead of a single page or post, right-click deactivate your new code module and navigate in your WordPress Admin to Divi > Theme Options > Integration.
Paste the code you copied from the code generator into the section called “Add Code to the of your blog”. Save your changes and check out the floating action menu now appearing on every page of your Divi website.
Well that’s all for this tutorial. If you have any questions about it let me know in the comments below. Likewise, if you have any requests for code module tutorials or what’s possible with the code module you can leave those too.
The post How to Add a Floating Action Menu to Divi with the Code Module appeared first on Elegant Themes Blog.