Skip to main content
All CollectionsTroubleshooting and FAQsFrequently Asked QuestionsGeneral
How to Create a Masonry Layout for Archive/Category Pages
How to Create a Masonry Layout for Archive/Category Pages

Learn how to leverage Divi’s features and advanced design techniques to achieve a responsive and stylish masonry layout for archive pages.

Updated over a week ago

A masonry layout can enhance the visual appeal and organization of your archive and category pages by displaying posts in an attractive, grid-like format that adjusts dynamically.

In this article, we will guide you through the process of creating a masonry layout for your archive pages using Divi's Theme Builder.

Out of the box, Divi will display all the posts on an Archive page using a standard layout that looks like this:

Divi - Default layout or Archive pages

You will have two different methods for changing the default Archive page layout:

Create the Archive template and layout using Theme Builder

  1. Go to WordPress Dashboard → Divi → Theme Builder

  2. Click on the Add New Template button

    Theme Builder - Create a new Template

  3. Choose the Build New Template option

  4. In the Template Settings list, choose All Archive Pages

    Theme Builder - Assign the template to Archive Pages

  5. Click on the Create Template button

  6. Click on the Add Custom Body option and choose Build Custom Body

  7. Click on the Green Plus Icon to insert a new Row

  8. Choose a 1 Column layout

    Theme Builder - Insert a one column row
  9. Search for and add the Blog module

  10. In the Content Tab → Content, enable the Post For Current Page option

    Theme Builder - Configure the Blog module to only show post related to the page in view

  11. Choose how many posts you want to display per page by changing the Post Count value

  12. Go to Design Tab → Layout and choose Grid

    Theme Builder - Set the Blog module's layout to Grid

  13. Save your changes and close the Visual Builder

  14. Save the Theme Builder changes by clicking on the Save Changes button

The final result can be seen in the image below:

Theme Builder - Final result

Note: Because the Blog module has the Post For Current Page option enabled, it will only display posts related to each archive page.

Examples:

  • If you are browsing the News category page, it will only show the Posts assigned to the News category.

  • If you are browsing the Author archive page, it will only show Posts published by that specific Author.

Pro Tip: The same template can also be assigned to the Search Results page.

In this case, the Search results page will use the same layout as above and display only Posts related to your search query.

Theme Builder - Assign a template to different type of pages

Customize the Archive Page's layout using Custom CSS

  1. Go to WordPress Dashboard → Divi → Theme Options → General Tab → Custom CSS

  2. Copy/Paste the following CSS Code:

    /* Remove sidebar on all archive pages */
    .search #main-content .container::before,
    .archive #main-content .container::before {
    display: none;
    }

    .search #left-area,
    .archive #left-area {
    width: 100%;
    float: none;
    padding-right: 0;
    }

    .search #sidebar,
    .archive #sidebar {
    display: none;
    }

    /* Create Mansonory styles for archive pages */
    .search #left-area,
    .archive #left-area {
    -moz-column-count: 3;
    column-count: 3;
    -moz-column-gap: 60px;
    column-gap: 60px;
    }

    .archive .et_pb_post > a,
    .search .et_pb_post > a {
    margin: -20px -20px 10px;
    display: block;
    }

    .search #left-area .et_pb_post,
    .archive #left-area .et_pb_post {
    overflow: hidden;
    /* fix for Firefox */
    page-break-inside: avoid;
    break-inside: avoid-column;
    width: 100%;
    padding: 19px;
    border: 1px solid #d8d8d8;
    background-color: #fff;
    word-wrap: break-word;
    display: inline-block;
    }

    .search #left-area .et_pb_post h2,
    .archive #left-area .et_pb_post h2 {
    font-size: 18px;
    }

    .search #left-area .et_pb_post.format-link,
    .search #left-area .et_pb_post.format-quote,
    .search #left-area .et_pb_post.format-audio,
    .archive #left-area .et_pb_post.format-link,
    .archive #left-area .et_pb_post.format-quote,
    .archive #left-area .et_pb_post.format-audio {
    padding: 0;
    }

    .archive .et_pb_post .et_pb_image_container,
    .archive .et_pb_post .et_main_video_container,
    .archive .et_pb_post .et_audio_content,
    .archive .et_pb_post .et_pb_slider,
    .search .et_pb_post .et_pb_image_container,
    .search .et_pb_post .et_main_video_container,
    .search .et_pb_post .et_audio_content,
    .search .et_pb_post .et_pb_slider {
    margin: -20px -20px 10px;
    }

    .archive .et_pb_post.format-audio .et_audio_content {
    margin: 0px -38px 0px;
    }

    .archive .et_pb_post .et_pb_slider .et_pb_slide,
    .search .et_pb_post .et_pb_slider .et_pb_slide {
    min-height: 180px;
    }

    .archive .pagination,
    .search .pagination {
    padding: 20px 0;
    }

    /* Media Queries */
    @media screen and (max-width: 980px) {

    .search #left-area,
    .archive #left-area {
    -moz-column-count: 2;
    column-count: 2;
    -moz-column-gap: 60px;
    column-gap: 60px;
    }
    }

    @media screen and (max-width: 767px) {

    .search #left-area,
    .archive #left-area {
    -moz-column-count: 1;
    column-count: 1;
    }

    .search .et_pb_post.format-audio .et_audio_content,
    .archive .et_pb_post.format-audio .et_audio_content {
    margin: 0;
    }

    .search #left-area .et_pb_post.format-audio .et_audio_container .mejs-controls div.mejs-time-rail,
    .archive #left-area .et_pb_post.format-audio .et_audio_container .mejs-controls div.mejs-time-rail,
    .search #left-area .et_pb_post.format-audio .et_audio_container .mejs-controls .mejs-time-rail .mejs-time-total,
    .archive #left-area .et_pb_post.format-audio .et_audio_container .mejs-controls .mejs-time-rail .mejs-time-total {
    min-width: 300px !important;
    width: 300px !important;
    }
    }

This will create a 3-column layout displaying 3 posts per row. However, you can still modify it to any number you'd like. To do that, in this CSS Code:

/* Create Mansonory styles for archive pages */
.search #left-area,
.archive #left-area {
-moz-column-count: 3;
column-count: 3;
-moz-column-gap: 60px;
column-gap: 60px;
}

Change the number 3 to the number of columns you want to have.

Bonus: Change the previous/next navigation to numbered navigation

You may also prefer to have your archive pages numbered instead of saying Older entries and Newer entries. For this, follow these steps:

  1. Install and activate the WP-PageNavi plugin

  2. Tweak its settings by going to WordPress Dashboard → Settings → PageNavi

  3. Add this JS code to Divi → Theme Option → Integration tab → Header

    <script>
    (function ($) {
    $(document).ready(function () {
    leftarea = $('#left-area');
    pageNavi = leftarea.find('.wp-pagenavi');
    pageNavigation = leftarea.find('.pagination');
    if (pageNavi.length) {
    pagenav = $('#left-area .wp-pagenavi');
    }
    else {
    pagenav = $('#left-area .pagination');
    }
    pagenav.detach();
    leftarea.after(pagenav);
    });
    })(jQuery)
    </script>
Did this answer your question?