• Resolved 2tyerd

    (@2tyerd)


    Hi

    I have a homepage where I am adding embeds on the daily.

    The problem is this is heavy on the server since all the embeds are loading at once so I want to add the ajax load more functionality.

    I came across this plugin but it seems that it is made for posts or pages with posts. The demo codes don’t look like they will work for my purpose.

    Can I use this to add a load more button to a page with embeds?

    My site is splitsthemiddle.com.au

    Thanks in advance

    • This topic was modified 7 years, 9 months ago by 2tyerd.
Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter 2tyerd

    (@2tyerd)

    I want to use this code from the demo example but instead of post_per_page=4, can I include scroll_distance=”150″?

    <?php 
    $term = $_GET['term'];
    if(empty($term){
       $term = 'WordPress';
    }
    echo do_shortcode('[ajax_load_more post_type="post, page, portfolio" search="'. $term .'" posts_per_page="4" scroll="true" css_classes="plain-text" button_label="Show More Results"]');
    ?>
    • This reply was modified 7 years, 9 months ago by 2tyerd.
    Plugin Author Darren Cooney

    (@dcooney)

    Hi @2tyerd,

    I want to use this code from the demo example but instead of post_per_page=4, can I include scroll_distance=”150″?

    Yes, it’s just a demo – you can do whatever you like to change that.

    The plugin is only for posts and pages but on Monday I am releasing a new addon that will make use of the <!--nextpage--> quicktag that will allow you to load more content on demand, not just pages… that might help you?

    Thread Starter 2tyerd

    (@2tyerd)

    That sounds like what I’m looking for…I look forward to checking it out.

    Plugin Author Darren Cooney

    (@dcooney)

    Hi @2tyerd,
    Just released the new add-on.
    https://connekthq.com/plugins/ajax-load-more/add-ons/next-page/

    It uses <!--nextpage--> quicktags to split content into pages.

    Hope this helps.

    Thread Starter 2tyerd

    (@2tyerd)

    Thanks for the msg man.

    Just bought it and trying to figure out where I need to put the shortcode.

    My homepage template code looks like this:

    get_header(); ?>
    
    	<div id="primary" class="content-area content-area-<?php echo rookie_get_sidebar_setting(); ?>-sidebar">
    		<main id="main" class="site-main" role="main">
    
    			<?php while ( have_posts() ) : the_post(); ?>
    
    				<?php get_template_part( 'content', 'homepage' ); ?>
    
    			<?php endwhile; // end of the loop. ?>
    
    		</main><!-- #main -->
    	</div><!-- #primary -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    <?php wp_link_pages(); ?>

    Which code should I replace with the shortcode?

    Plugin Author Darren Cooney

    (@dcooney)

    Cool thanks.
    Well that depends on what it in that function call get_template_part homepage.

    What you want to do is replace the area that you have the_content() with the shortcode.

    If you need more help open a ticket on the website and I can investigate further.

    Thread Starter 2tyerd

    (@2tyerd)

    I have another template thats used for displaying content on the homepage

    <?php
    /**
     * The template used for displaying homepage content.
     *
     * @package Rookie
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. ?>
    		<header class="entry-header">
    			<?php the_post_thumbnail( 'large' ); ?>
    		</header><!-- .entry-header -->
    	<?php } ?>
    
    	<div class="entry-content">
    		<div class="homepage-widgets">
    			<?php dynamic_sidebar( 'homepage-1' ); ?>
    		</div>
    
    		<?php the_content(); ?>
    	</div><!-- .entry-content -->
    </article><!-- #post-## -->

    Not sure which to use

    Thread Starter 2tyerd

    (@2tyerd)

    ok yeah sweet I’ll open a ticket

    Thread Starter 2tyerd

    (@2tyerd)

    Okay so I’ve gone with the second template, I’m pretty sure thats the right one.

    So I replaced the the_content() with the shortcode [ajax_load_more nextpage="true" nextpage_urls="true" nextpage_scroll="350:30" nextpage_post_id="'. get_the_ID() .'" pause="true" pause_override="true" button_label="Next Page" images_loaded="true" transition="fade" container_type="div"]

    So it looks like this now:

    <?php
    /**
     * The template used for displaying homepage content.
     *
     * @package Rookie
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<?php if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. ?>
    		<header class="entry-header">
    			<?php the_post_thumbnail( 'large' ); ?>
    		</header><!-- .entry-header -->
    	<?php } ?>
    
    	<div class="entry-content">
    		<div class="homepage-widgets">
    			<?php dynamic_sidebar( 'homepage-1' ); ?>
    		</div>
    
    		<?php echo do_shortcode('[ajax_load_more nextpage="true" nextpage_urls="true" nextpage_scroll="350:30" nextpage_post_id="'. get_the_ID() .'" pause="true" pause_override="true" button_label="Next Page" images_loaded="true" transition="fade" container_type="div"]'); ?>
    	
    </div><!-- .entry-content -->
    </article><!-- #post-## -->

    Nothing changed though. Where have I messed up?

    • This reply was modified 7 years, 9 months ago by 2tyerd.
    • This reply was modified 7 years, 9 months ago by 2tyerd.
Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Lazy loading Embeds’ is closed to new replies.