Title: Lazy loading Embeds
Last modified: February 11, 2017

---

# Lazy loading Embeds

 *  Resolved [2tyerd](https://wordpress.org/support/users/2tyerd/)
 * (@2tyerd)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/)
 * 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 9 years, 1 month ago by [2tyerd](https://wordpress.org/support/users/2tyerd/).

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

 *  Thread Starter [2tyerd](https://wordpress.org/support/users/2tyerd/)
 * (@2tyerd)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8794955)
 * 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 9 years, 1 month ago by [2tyerd](https://wordpress.org/support/users/2tyerd/).
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8795065)
 * Hi [@2tyerd](https://wordpress.org/support/users/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](https://codex.wordpress.org/Write_Post_SubPanel#Quicktags)
   that will allow you to load more content on demand, not just pages… that might
   help you?
 *  Thread Starter [2tyerd](https://wordpress.org/support/users/2tyerd/)
 * (@2tyerd)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8795101)
 * That sounds like what I’m looking for…I look forward to checking it out.
 *  Plugin Author [Darren Cooney](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8804233)
 * Hi [@2tyerd](https://wordpress.org/support/users/2tyerd/),
    Just released the
   new add-on. [https://connekthq.com/plugins/ajax-load-more/add-ons/next-page/](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](https://wordpress.org/support/users/2tyerd/)
 * (@2tyerd)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8805562)
 * 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](https://wordpress.org/support/users/dcooney/)
 * (@dcooney)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8805587)
 * 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](https://wordpress.org/support/users/2tyerd/)
 * (@2tyerd)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8805591)
 * 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](https://wordpress.org/support/users/2tyerd/)
 * (@2tyerd)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8805594)
 * ok yeah sweet I’ll open a ticket
 *  Thread Starter [2tyerd](https://wordpress.org/support/users/2tyerd/)
 * (@2tyerd)
 * [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8805712)
 * 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 9 years, 1 month ago by [2tyerd](https://wordpress.org/support/users/2tyerd/).
    -  This reply was modified 9 years, 1 month ago by [2tyerd](https://wordpress.org/support/users/2tyerd/).

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

The topic ‘Lazy loading Embeds’ is closed to new replies.

 * ![](https://ps.w.org/ajax-load-more/assets/icon-256x256.png?rev=2944639)
 * [Ajax Load More – Infinite Scroll, Load More, & Lazy Load](https://wordpress.org/plugins/ajax-load-more/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/ajax-load-more/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/ajax-load-more/)
 * [Active Topics](https://wordpress.org/support/plugin/ajax-load-more/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/ajax-load-more/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/ajax-load-more/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [2tyerd](https://wordpress.org/support/users/2tyerd/)
 * Last activity: [9 years, 1 month ago](https://wordpress.org/support/topic/lazy-loading-embeds/#post-8805712)
 * Status: resolved