{"id":28999,"date":"2023-10-09T12:55:57","date_gmt":"2023-10-09T07:55:57","guid":{"rendered":"https:\/\/mcstarters.com\/blog\/?p=28999"},"modified":"2024-01-10T17:56:02","modified_gmt":"2024-01-10T12:56:02","slug":"add-a-load-more-button-in-the-divi-blog-module","status":"publish","type":"post","link":"https:\/\/mcstarters.com\/blog\/add-a-load-more-button-in-the-divi-blog-module\/","title":{"rendered":"How to Add a Load More Button in the Divi Blog Module"},"content":{"rendered":"\n<p>Are you looking for a way to add a load more button in the Divi blog module?<\/p>\n\n\n\n<p>If you&#8217;re using the popular Divi theme for your WordPress website, you&#8217;ve likely discovered its flexibility and ease of use. Divi empowers you to create stunning designs and layouts without needing to be a coding expert. One handy feature you might want to implement on your blog page is a &#8220;Load More&#8221; button. This button allows visitors to view additional blog posts without having to navigate away from the page. <\/p>\n\n\n\n<p>In this tutorial, we&#8217;ll walk you through the steps to add a load more button in the Divi blog module.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Steps to Add a Load More Button in the Divi Blog Module:<\/strong><\/h2>\n\n\n\n<p>Discover the steps to effortlessly add a Load More button in the Divi Blog Module, enhancing your WordPress website&#8217;s user experience.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Disable Pagination<\/strong><\/h3>\n\n\n\n<p class=\"step\"><strong>Step 1:<\/strong> Access the module settings. <\/p>\n\n\n\n<p class=\"step\"><strong>Step 2:<\/strong> Go to the Content tab. <\/p>\n\n\n\n<p class=\"step\"><strong>Step 3:<\/strong> Find the Elements section. <\/p>\n\n\n\n<p class=\"step\"><strong>Step 4:<\/strong> Set &#8220;Show Pagination&#8221; to NO.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mcstarters.com\/blog\/wp-content\/uploads\/2023\/10\/6.gif\" alt=\"Disable Pagination\" class=\"wp-image-29015\" style=\"object-fit:cover;width:338px;height:447px\" width=\"338\" height=\"447\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Add a Unique CSS Class Name<\/strong><\/h3>\n\n\n\n<p class=\"step\"><strong>Step 1:<\/strong> Access the module settings. <\/p>\n\n\n\n<p class=\"step\"><strong>Step 2:<\/strong> Click on the &#8220;Advanced&#8221; tab.<\/p>\n\n\n\n<p class=\"step\"><strong>Step 3:<\/strong> Find the CSS ID &amp; Classes section.<\/p>\n\n\n\n<p class=\"step\"><strong>Step 4:<\/strong> Add the class &#8220;load_more_mc_starters_blog&#8221; in the CSS Class input field.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-resized\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/mcstarters.com\/blog\/wp-content\/uploads\/2023\/10\/Untitled.png\" alt=\"Add a Unique CSS Class Name\" class=\"wp-image-29019\" style=\"width:338px;height:447px\" width=\"338\" height=\"447\" title=\"\"><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Add the Button Module<\/h3>\n\n\n\n<p class=\"step\"><strong>Step 1:<\/strong> Below the Blog module, add a new Button module.<\/p>\n\n\n\n<p class=\"step\"><strong>Step 2:<\/strong> Customize the Button module to create the &#8220;Load More&#8221; button to your liking.<\/p>\n\n\n\n<p class=\"step\"><strong>Step 3:<\/strong> In the Button module settings, go to the &#8220;Advanced&#8221; tab and select &#8220;CSS ID &amp; Classes.&#8221;<\/p>\n\n\n\n<p class=\"step\"><strong>Step 4:<\/strong> Add the CSS ID &#8220;load_more_mc_starters_blog&#8221; to link the Blog module and the &#8220;Load More&#8221; button properly.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Add the JavaScript Snippet<\/strong><\/h3>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/mcstarters.com\/blog\/wp-content\/uploads\/2023\/10\/5.png\" alt=\"Add the JavaScript Snippet\" class=\"wp-image-29023\" title=\"\"><\/figure>\n\n\n\n<p class=\"step\"><strong>Step 1:<\/strong> Go to the WordPress dashboard. Click on Divi -> Theme Options<\/p>\n\n\n\n<p class=\"step\"><strong>Step 2:<\/strong> Click on the &#8220;Integration&#8221; tab.<\/p>\n\n\n\n<p class=\"step\"><strong>Step 3:<\/strong> Paste the given JavaScript snippet into the &#8220;Add code to the &lt;head> of your blog&#8221; field.<\/p>\n\n\n\n<pre class=\"wp-block-code bg-code\"><code>&lt;script>\r\njQuery(document).ready(function(){\r\n    \/\/ Check if the screen width is below 767px (for mobile screens)\r\n    if (window.matchMedia('(max-width: 767px)').matches) {\r\n        var initial_show_article = 3; \/\/ Number of articles initially displayed\r\n        var article_reveal = 2; \/\/ Number of articles to reveal on each button click\r\n\r\n        \/\/ Hide articles beyond the initial display count\r\n        jQuery(\".load_more_mc_starters_blog\").not( \":nth-child(-n+\"+initial_show_article+\")\" ).css(\"display\",\"none\");\r\n\r\n        \/\/ When the \"Load More\" button is clicked\r\n        jQuery(\"#ap_load_more_button_id\").on(\"click\", function(event){\r\n            event.preventDefault();\r\n\r\n            \/\/ Increase the count of displayed articles\r\n            initial_show_article = initial_show_article + article_reveal;\r\n\r\n            \/\/ Display additional articles\r\n            jQuery(\".load_more_mc_starters_blog\").css(\"display\",\"block\");\r\n\r\n            \/\/ Hide articles beyond the updated display count\r\n            jQuery(\".load_more_mc_starters_blog\").not( \":nth-child(-n+\"+initial_show_article+\")\" ).css(\"display\",\"none\");\r\n\r\n            \/\/ Check if all articles are displayed and hide the button if necessary\r\n            var articles_num = jQuery(\".load_more_mc_starters_blog\").not('&#91;style*=\"display: block\"]').length;\r\n            if (articles_num == 0){\r\n                jQuery(this).css(\"display\",\"none\");    \r\n            }   \r\n        })\r\n    } else {\r\n        \/\/ For desktop screens\r\n        var initial_row_show = 2; \/\/ Number of rows initially displayed\r\n        var row_reveal = 1; \/\/ Number of rows to reveal on each button click\r\n\r\n        var total_articles = jQuery(\".load_more_mc_starters_blog\").length;\r\n\r\n        \/\/ Hide articles beyond the initial row display count\r\n        jQuery(\".load_more_mc_starters_blog\").not( \":nth-child(-n+\"+initial_row_show+\")\" ).css(\"display\",\"none\");\r\n\r\n        \/\/ When the \"Load More\" button is clicked\r\n        jQuery(\"#ap_load_more_button_id\").on(\"click\", function(event){\r\n            event.preventDefault();\r\n\r\n            \/\/ Increase the count of displayed rows\r\n            initial_row_show = initial_row_show + row_reveal;\r\n\r\n            \/\/ Display additional rows\r\n            jQuery(\".load_more_mc_starters_blog\").css(\"display\",\"block\");\r\n\r\n            \/\/ Hide rows beyond the updated display count\r\n            jQuery(\".load_more_mc_starters_blog\").not( \":nth-child(-n+\"+initial_row_show+\")\" ).css(\"display\",\"none\");\r\n\r\n            \/\/ Check if all rows are displayed and hide the button if necessary\r\n            var articles_num = jQuery(\".load_more_mc_starters_blog\").not('&#91;style*=\"display: block\"]').length;\r\n            if (articles_num == 0){\r\n                jQuery(this).css(\"display\",\"none\");    \r\n            }    \r\n        })\r\n    } \r\n})\r\n&lt;\/script>\r<\/code><\/pre>\n\n\n\n<p class=\"step\"><strong>Step 4:<\/strong> Save your changes to activate the &#8220;Load More&#8221; button feature on your Divi Blog Module.<\/p>\n\n\n\n<p>By following these steps, you&#8217;ll enable the add a load more button in the Divi blog module.<\/p>\n\n\n\n<p>After adding the button, save your changes and exit the <a  class=\"btl_autolink_hyperlink\"  href=\"https:\/\/mcstarters.com\/blog\/divi-aff\"    target=\"_blank\" rel=\"nofollow\">Divi Builder<\/a>. View your page, and you should see the &#8220;Load More&#8221; button at the bottom of your blog posts. Clicking it will load additional posts without reloading the page.<\/p>\n\n\n\n<p>Congratulations! You&#8217;ve successfully added a &#8220;Load More&#8221; button to your Divi Blog Module, enhancing the user experience on your WordPress website. Visitors can now explore more of your content with ease.<\/p>\n\n\n\n<p>Remember to adjust the JavaScript code and button design to fit your specific needs and styling preferences. Happy blogging with Divi!<\/p>\n\n\n<div id=\"rank-math-faq\" class=\"rank-math-block\">\n<div class=\"rank-math-list \">\n<div id=\"faq-question-1696835826879\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>What is the purpose of assigning a CSS class and ID to the Blog and Button modules?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Assigning a CSS class (e.g., &#8220;load_more_mc_starters_blog&#8221;) to the Blog module and a CSS ID (e.g., &#8220;ap_load_more_button_id&#8221;) to the Button module helps link them and allows the JavaScript code to control their interactions for the &#8220;Load More&#8221; functionality.<\/p>\n\n<\/div>\n<\/div>\n<div id=\"faq-question-1696835867241\" class=\"rank-math-list-item\">\n<h3 class=\"rank-math-question \"><strong>Can I customize the number of initial posts displayed and the increment on each click of the &#8220;Load More&#8221; button?<\/strong><\/h3>\n<div class=\"rank-math-answer \">\n\n<p>Yes, you can customize these settings in the JavaScript code. Depending on screen width (mobile or desktop), you can adjust the initial_show_article, article_reveal, initial_row_show, and row_reveal variables to control the display and increment of posts or rows.<\/p>\n\n<\/div>\n<\/div>\n<\/div>\n<\/div>","protected":false},"excerpt":{"rendered":"<p>Are you looking for a way to add a load&#8230;<\/p>\n","protected":false},"author":2,"featured_media":29011,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[6],"tags":[488,322],"class_list":["post-28999","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-divi","tag-divi-guide","tag-divipagebuilder"],"_links":{"self":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/posts\/28999","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/comments?post=28999"}],"version-history":[{"count":0,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/posts\/28999\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/media\/29011"}],"wp:attachment":[{"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/media?parent=28999"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/categories?post=28999"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mcstarters.com\/blog\/wp-json\/wp\/v2\/tags?post=28999"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}