If you want to display Adsense or other banner on the left sidebar in the Divi theme here is how you can do this.
Divi doesn’t provide non-program way to display left sidebar. Lets start with this.
Adding widget
Go to Dashboard -> Appearance -> Widgets where you can see ET Adsense Widget. Drag and drop it onto Sidebar
Put your code inside Adsense Code text field. Write the title your wish into Title text field. Sadly if you wish no title you can’t just clear Title field. Divi will display default title ‘Adsense’ above your banner in this case. To remove title you need to add
1 |
.widget_adsensewidget .widgettitle { display: none; } |
to ePanel Custom CSS or to your child theme’s CSS file.
Expand Adsense Widget
If your Adsense widget wider than sidebar your can add next CSS to expand it
1 |
.widget_adsensewidget { width: 240px; } |
Left sidebar
Theres is no user friendly way in Divi to move sidebar to the left for all posts. You can do it only for each post. The solution is good describing by Daniel Pataki in this article. We have to add hook to functions.php in our child theme
1 2 3 4 5 6 7 8 9 10 11 12 |
function divi_child_body_classes($classes) { if (is_single()) { $key = array_search('et_right_sidebar', $classes); if (!empty($key)) { unset($classes[$key]); } $classes[] = 'et_left_sidebar'; } return $classes; } add_filter('body_class', 'divi_child_body_classes', 20); |
Expand left sidebar
Now we have our adsense widget on the left sidebar but part of it laid over main content.
To correct this we have to add next CSS(supposing that we have 240px width Adsense widget)
1 2 |
.single div#left-area { position: relative; left: 50px; } .single #main-content .container:before { left: 248px !important; } |
Trackbacks/Pingbacks