Advertisements
In order to create an infinite loop on the Post Navigation module, so that your “Previous/Next” buttons continue on after the first/last posts, you can try the following:
- Upload the Loop Post Navigation Links plugin.
https://wordpress.org/plugins/loop-post-navigation-links/ - Modify the Posts Navigation Module in your Child Theme
- Copy the PostsNavigation.php from Divi/includes/builder/module folder
- Paste file into custom-modules folder inside your Divi Child Theme folder (if you do not have a folder named “custom-modules”, create one)
- Rename the pasted file to customPostsNavigation.php
- Open customPostsNavigation.php and replace this line (at the very top):
class ET_Builder_Module_Posts_Navigation extends ET_Builder_Module
with:
class custom_ET_Builder_Module_Posts_Navigation extends ET_Builder_Module - Next, replace: $this->vb_support = ‘on’; with $this->vb_support = ‘off’;
- Then, comment out this line from the bottom: new ET_Builder_Module_Blog();
- Now find get_next_post and replace with c2c_get_next_or_loop_post (around line 260)
- Then, find get_previous_post and replace with c2c_get_previous_or_loop_post (around line 284)
- Save customPostsNavigation.php
- Lastly, add the following code to your functions.php file.
function divi_custom_postnav_module() {
get_template_part( 'custom-modules/customPostsNavigation' );
$dcfm = new custom_ET_Builder_Module_Posts_Navigation();
remove_shortcode( 'et_pb_post_nav' );
add_shortcode( 'et_pb_post_nav', array( $dcfm, '_shortcode_callback' ) ); }add_action( 'et_builder_ready', 'divi_custom_postnav_module' );function divi_custom_postnav_class( $classlist ) {
// Posts Navigation Module 'classname' overwrite.
$classlist['et_pb_post_nav'] = array( 'classname' => 'custom_ET_Builder_Module_Posts_Navigation',);
return $classlist;
}add_filter( 'et_module_classes', 'divi_custom_postnav_class' );