Support » Plugin: WordPress Infinite Scroll - Ajax Load More » Load more on initial

  • Resolved TamerDesigns

    (@dribgib)


    How can I get more products to load initially – it’s only loading whatever my screen can show- can I define a # of products to load at first? It also only loads in 4 products at a time as I scroll down (again what fills my screen). Any control over this?

    https://merakimoon.staging.wpengine.com/shop/

    [ajax_load_more container_type=”div” repeater=”template_1″ post_type=”product” posts_per_page=”30″ scroll_distance=”0″ transition=”fade” images_loaded=”true” pause=”false” pause_override=”false” preloaded=”true”]

    • This topic was modified 2 years, 6 months ago by  TamerDesigns.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author dcooney

    (@dcooney)

    Hi @dribgib,
    That is only possible if you load initial posts using your own query before Ajax Load More or by using the Preloaded add-on.

    Hope this helps.

    • This reply was modified 2 years, 6 months ago by  dcooney.

    That helped a bit – now I’m seeing inconsistent # of loads when I scroll down… it’s set to 8 but it occasionally loads 6, or 16 – seems random… This breaks my grid because the alm-reveal div creates a new row. Any ideas why that’s happening?

    [ajax_load_more preloaded=”true” repeater=”template_1″ post_type=”product” posts_per_page=”8″ scroll_distance=”50″ transition=”fade” images_loaded=”true” pause=”false” pause_override=”false”]

    https://merakimoon.staging.wpengine.com/shop/

    Here’s my template – which is hacked together from the Jupiter Theme and I’m not expert so I’m certain there are pieces of this that are not needed…

    <?php

    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly

    global $product, $woocommerce_loop, $mk_options;

    // Ensure visibility
    if ( ! $product->is_visible() ){
    return;
    }

    // declare variable in case if none of the conditions below meets

    $classes= ‘item mk–col mk–col–3-12 product type-product status-publish has-post-thumbnail taxable shipping-taxable purchasable product-type-variable has-children item–loaded’;
    ?>

    <li <?php post_class($classes); ?>>
    <div class=”mk-product-holder”>
    <div class=”product-loop-thumb”>
    <?php

    if ( ! $product->is_in_stock() ) {
    echo ‘<span class=”mk-out-stock”>’.__( ‘OUT OF STOCK’, ‘mk_framework’ ).'</span>’;
    }

    if ($product->is_on_sale()) :
    echo apply_filters(‘woocommerce_sale_flash’, ‘<span class=”mk-onsale”>’.__( ‘Sale’, ‘mk_framework’ ).'</span>’, $post, $product);
    endif;

    $image_size = isset($mk_options[‘woo_loop_image_size’]) ? $mk_options[‘woo_loop_image_size’] : ‘crop’;

    if ( has_post_thumbnail() ) {

    echo ‘‘;

    $featured_image_src = Mk_Image_Resize::resize_by_id_adaptive( get_post_thumbnail_id(), $image_size, $width, $height, $crop = false, $dummy = true);

    if ( has_post_thumbnail() ) { the_post_thumbnail(array(500,500));}

    echo ‘‘;

    } else {

    echo ‘Placeholder‘;

    }
    ?>

    <?php if($mk_options[‘woocommerce_catalog’] == ‘false’) { ?>
    <div class=”product-item-footer”>
    <?php if ( $rating_html = $product->get_rating_html() ) : ?>
    <span class=”product-item-rating”><?php echo $rating_html; ?></span>
    <?php endif; ?>

    <?php
    /**
    * woocommerce_after_shop_loop_item hook
    *
    * @hooked woocommerce_template_loop_add_to_cart – 10
    */
    do_action( ‘woocommerce_after_shop_loop_item’ );

    switch ( $product->product_type ) {
    case “variable” :
    $icon_class = ‘mk-icon-plus’;
    break;
    case “grouped” :
    $icon_class = ‘mk-moon-search-3’;
    break;
    case “external” :
    $icon_class = ‘mk-moon-search-3’;
    break;
    default :
    $icon_class = ‘mk-moon-cart-plus’;
    break;
    }

    if(!$product->is_purchasable() || !$product->is_in_stock()) {
    $icon_class = ‘mk-moon-search-3’;
    }

    $button_class = implode( ‘ ‘, array(
    ‘product_loop_button’,
    ‘product_type_’ . $product->product_type,
    $product->is_purchasable() && $product->is_in_stock() ? ‘add_to_cart_button’ : ”,
    $product->supports( ‘ajax_add_to_cart’ ) ? ‘ajax_add_to_cart’ : ”
    ) );

    echo apply_filters( ‘woocommerce_loop_add_to_cart_link’,
    sprintf( ‘%s%s‘,
    esc_url( $product->add_to_cart_url() ),
    esc_attr( $quantity ),
    esc_attr( $product->id ),
    esc_attr( $product->get_sku() ),
    esc_attr( $button_class ),
    Mk_SVG_Icons::get_svg_icon_by_class_name(false,$icon_class,16),
    esc_html( $product->add_to_cart_text() )
    ),
    $product );

    ?>
    </div>
    <?php } ?>
    </div>
    <?php do_action( ‘woocommerce_before_shop_loop_item’ ); ?>

    <div class=”mk-shop-item-detail”>
    <?php
    global $mk_options;
    if ( ! empty( $mk_options[‘woocommerce_loop_enable_love_button’] ) ) :
    if ( $mk_options[‘woocommerce_loop_enable_love_button’] != ‘false’ ) :
    ?>
    <div class=”mk-love-holder”>
    <?php echo Mk_Love_Post::send_love(); ?>
    </div>
    <?php
    endif;
    endif;
    ?>

    <h3 class=”product-title”>“><?php the_title(); ?></h3>
    <?php do_action( ‘woocommerce_after_shop_loop_item_title’ ); ?>

    <?php
    if($mk_options[‘woocommerce_loop_show_desc’] == ‘true’) :
    echo ‘<div class=”product-item-desc”>’ . apply_filters( ‘woocommerce_short_description’, $post->post_excerpt ) . ‘</div>’;
    endif;
    ?>
    </div>
    </div>

    Plugin Author dcooney

    (@dcooney)

    I’m not really sure what is going on here – The link you sent is no longer working so I cant see what the issue would be.

    If possible, I would suggest trying to simplify the template though… looks pretty complicated.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Load more on initial’ is closed to new replies.