• Hi,

    I’m using your wonderful template on my new site http://www.nadrchal.com/wordpress/ and am trying to edit it to have an infinite number of photos on the main page. Obviously, I don’t want to have hundred of photos to be loaded when the page is opened, so I was trying find some infinite scroll plugin. I’m quite a noobie when it comes to page coding… and I got lost. I was able to add the Ajax Load More script to the page, but the posts are not loaded in the masonry. Can you please help me with that? I know I need to adjust the javascript somehow, but my skills are not high enough to do that..

    Thanks!

    Tomas

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi,

    Did you try this plugin, Because Its still works with news themes.

    https://wordpress.org/plugins/infinite-scroll/

    I noticed on your homepage, only one column of Photos is being. These should load fully, Have you looked at customization.

    Other suggestion is try this.
    http://www.infinite-scroll.com/

    Or let me know if you still need my help.

    Thread Starter hammer07

    (@hammer07)

    Thanks, tried, but the same thing happens even with this plugin… It seems like it doesn’t work with the masonry. If you have any other tips, I’ll be very grateful.

    Thx

    Hi hammer07

    Try downloading jetpack plugin from here https://wordpress.org/plugins/jetpack/.
    Now install this plugin.
    And you need to follow the steps described in this link http://ottopress.com/2012/jetpack-and-the-infinite-scroll/
    Feel free to post if problem continues.

    Best Regards!!

    Thread Starter hammer07

    (@hammer07)

    Hi WEN,

    thanks for your help. Unfortunately I’m a real noob and am not able to finish it… In the post they say that I should separate the post part, but in your template there is only another function…

    `<?php while ( have_posts() ) : the_post(); ?>
    <?php
    do_action( ‘photo_perfect_action_loop’ );
    ?>
    <?php
    endwhile; ?>`

    I was trying to figure it out for quite a time and I’m lost.. Maybe I’ll just leave it the way I have it now and get back to it when I have more time to study πŸ™‚

    thanks a lot anyway, if you could help me a bit more, I’d appreciate it, but if you cannot, it’s ok… btw – moved my site to the domain, http://www.nadrchal.com it is now, in case you’d like to check πŸ™‚

    tomas

    Hello @hammer07,
    Just some steps and you are done for the infinite scroll.

    1. Install and activate Jetpack plugin mentioned above.
    2. Go to Jetpack settings page and activate ‘Infinite Scroll’.
    3. Create a child theme and put the below codes in child theme’s ‘functions.php’:

    function pp_jetpack_setup() {
        // Add theme support for Infinite Scroll.
        add_theme_support( 'infinite-scroll', array(
            'container' => 'main',
            'render'    => 'pp_infinite_scroll_render',
            'footer'    => 'page',
        ) );
    
        // Add theme support for Responsive Videos.
        add_theme_support( 'jetpack-responsive-videos' );
    }
    add_action( 'after_setup_theme', 'pp_jetpack_setup' );
    
    /**
    * Custom render function for Infinite Scroll.
    */
    function pp_infinite_scroll_render() {
        while ( have_posts() ) {
            the_post();
            if ( is_search() ) :
                get_template_part( 'template-parts/content', 'search' );
            else :
                get_template_part( 'template-parts/content-masonry', get_post_format() );
            endif;
        }
    }

    4. Go to Settings > Reading and check the boxes that says ‘ Scroll Infinitely’ and ‘ Track each Infinite Scroll post load as a page view in Google Analytics’ and save changes. See the screenshot: http://prntscr.com/a0vmqp

    5. Add the below CSS in Customizing > Theme Options
    Advanced Options > Custom CSS:

    .masonry-entry {
       float: left;
    }

    And this should do it. Try this and let us know about it.

    Note: How to create a child theme? https://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme

    Thanks!

    regards,

    Thread Starter hammer07

    (@hammer07)

    WEN, you are awesome! Thanks a lot!

    It worked, there are only a small tweaks I need to figure out somehow. Check my page now – http://www.nadrchal.com you can see that the masonry doesn’t continue “fluently”… I will try looking into that, if you have any other awesome ideas, I’ll be more than grateful.

    Thx
    Tomas

    Hello @hammer07,
    The free version of ‘Photo perfect’ theme does not support infinite scroll by default. And that is why i have provided you some hints through customization. I checked in your site and the issue has occurred on the infinite scroll as a result of theme being not adaptive to infinite scroll by default as i mentioned. Whereas, the features works very nicely on the pro version. I can only tell you to add the following js code in the theme and see if it works.

    jQuery(document).ready(function($) {
    
    		if ( $( 'body').hasClass( 'archive-layout-masonry' ) && $( '#masonry-loop' ).length > 0 ) {
    			//Masonry blocks
    			$blocks = $("#main");
    
    			$blocks.imagesLoaded(function(){
    				$blocks.masonry({
    					"columnWidth": ".hentry",
    					"itemSelector": ".hentry",
    					"percentPosition": true
    				});
    
    				// Fade blocks in after images are ready (prevents jumping and re-rendering)
    				$(".hentry").fadeIn();
    			});
    
    			// $(document).ready( function() { setTimeout( function() { $blocks.masonry(); }, 500); });
    
    			$(window).resize(function () {
    				$blocks.masonry();
    			});
    
    			// When Jetpack Infinite scroll posts have loaded
    			$( document.body ).on( 'post-load', function () {
    
    				var $container = $('#main');
    				// $container.masonry( 'reloadItems' );
    
    				$blocks.imagesLoaded(function(){
    					$blocks.masonry({
    						"columnWidth": ".hentry",
    						"itemSelector": ".hentry",
    						"percentPosition": true
    					});
    
    					// Fade blocks in after images are ready (prevents jumping and re-rendering)
    					$(".hentry").fadeIn();
    				});
    
    				$container.masonry( 'reloadItems' );
    
    				// $(document).ready( function() { setTimeout( function() { $blocks.masonry(); }, 500); });
    
    			});
    
    		}; //End if masnory is activated
    
    	});

    Thank you!

    Thread Starter hammer07

    (@hammer07)

    Hi WEN Solutions!

    Thank you again for your help, unfortunately this didn’t help either, it has caused the same effect as I had before with my previous attempts, all pictures aligned to the left, weird. I must have done something wrong. You are the best anyway… I have switched the infitine scroll off and will settle down with the current layout and consider purchasing the PRO version …

    Have a nice weekend!

    Tomas

    Hello @hammer07,
    Switching to PRO theme will definitely resolve your issue as it supports infinite scroll by default and you won’t need any customization. There are also other awesome features, you can check that here: http://themepalace.com/shop/wordpress-themes/photo-perfect-pro/

    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘infinite scroll on homepage’ is closed to new replies.