So, I’m in the process of putting the final touches on part two of my child themes series when I get a request from another Divi developer, Patricia. She is building a site for a client and she wants the post category list view to not show the sidebar. What a perfect way to showcase the power of a child theme.
Step 1 – Prepare the template
Patricia was already working in a child theme (experienced developer that she is), so I didnt need to create one for her. As Patricia wants to manipulate the category list view, all I have to do is create an archive.php file inside her child theme, copy all the code inside the index.php file from the Divi theme to the child theme archive.php file and make some changes.
This is the contents of /themes/Divi/index.php
The two things we need to remove are the ‘left-area’ div article list wrapper, and the get_sidebar(); function call. (You could also just leave the left-area div there if you want and style it to be wider but I prefer to remove it entirely)
So our new /themes/child-theme/archive.php file looks like this:
Step 2 – add some style
If you just implement the archive.php as is you will see that the borderline between the content and the sidebar still appears. This is because Elegant Themes have implmented this border on the before psuedo class of the ‘content-area’ div. So we need to add a little CSS to our child theme style.css file to effectively ‘hide’ the border.
And that’s it. One template, remove a couple of lines of code, a small css snippet and all your article archive/category pages will now no longer have the default sidebar. I’ve created a GitHub repository if you want to download the files to use in your next project.
Leave a Reply to Robert Cancel reply