2017-01-22 2 views
0

Ich mag wissen würde, wie Standard-Paginierung auf WooCommerce in unendliche Scrollen wie folgt ersetzen: http://shop.ugmonk.com/collections/clothing-allSo erstellen Infinite Paginierung auf WooCommerce durch PHP

Das ist meine Produktseite: http://cardstory.co/collections

ich vor kurzem verwendet Plugin, um dies zu erreichen, aber mit Plugin verursacht einige Störungen auf der Produktseite (einige Produkte nicht alphabetisch in der Reihenfolge angezeigt und es gab einige weiße Leerzeichen am Ende der Produktgalerie).

Dies ist der aktuelle Standard-pagination.php Code:

<?php 
/** 
* Pagination - Show numbered pagination for catalog pages 
* 
* This template can be overridden by copying it to yourtheme/woocommerce/loop/pagination.php. 
* 
* HOWEVER, on occasion WooCommerce will need to update template files and you 
* (the theme developer) will need to copy the new files to your theme to 
* maintain compatibility. We try to do this as little as possible, but it does 
* happen. When this occurs the version of the template file will be bumped and 
* the readme will list any important changes. 
* 
* @see   https://docs.woocommerce.com/document/template-structure/ 
* @author  WooThemes 
* @package  WooCommerce/Templates 
* @version  2.2.2 
*/ 

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

global $wp_query; 

if ($wp_query->max_num_pages <= 1) { 
    return; 
} 
?> 
<nav class="woocommerce-pagination"> 
    <?php 
     echo paginate_links(apply_filters('woocommerce_pagination_args', array(
      'base'   => esc_url_raw(str_replace(999999999, '%#%', remove_query_arg('add-to-cart', get_pagenum_link(999999999, false)))), 
      'format'  => '', 
      'add_args'  => false, 
      'current'  => max(1, get_query_var('paged')), 
      'total'  => $wp_query->max_num_pages, 
      'prev_text' => '&larr;', 
      'next_text' => '&rarr;', 
      'type'   => 'list', 
      'end_size'  => 3, 
      'mid_size'  => 3 
     ))); 
    ?> 
</nav> 

Und das ist der Archiv-product.php Code:

<?php 
/** 
* The Template for displaying product archives, including the main shop page which is a post type archive 
* 
* This template can be overridden by copying it to yourtheme/woocommerce/archive-product.php. 
* 
* HOWEVER, on occasion WooCommerce will need to update template files and you 
* (the theme developer) will need to copy the new files to your theme to 
* maintain compatibility. We try to do this as little as possible, but it does 
* happen. When this occurs the version of the template file will be bumped and 
* the readme will list any important changes. 
* 
* @see   https://docs.woocommerce.com/document/template-structure/ 
* @author  WooThemes 
* @package  WooCommerce/Templates 
* @version  2.0.0 
*/ 

if (! defined('ABSPATH')) { 
    exit; // Exit if accessed directly 
} 

get_header('shop'); ?> 

    <?php 
     /** 
     * woocommerce_before_main_content hook. 
     * 
     * @hooked woocommerce_output_content_wrapper - 10 (outputs opening divs for the content) 
     * @hooked woocommerce_breadcrumb - 20 
     */ 
     do_action('woocommerce_before_main_content'); 
    ?> 

     <?php if (apply_filters('woocommerce_show_page_title', true)) : ?> 

      <h1 class="page-title"><?php woocommerce_page_title(); ?></h1> 

     <?php endif; ?> 

     <?php 
      /** 
      * woocommerce_archive_description hook. 
      * 
      * @hooked woocommerce_taxonomy_archive_description - 10 
      * @hooked woocommerce_product_archive_description - 10 
      */ 
      do_action('woocommerce_archive_description'); 
     ?> 

     <?php if (have_posts()) : ?> 

      <?php 
       /** 
       * woocommerce_before_shop_loop hook. 
       * 
       * @hooked woocommerce_result_count - 20 
       * @hooked woocommerce_catalog_ordering - 30 
       */ 
       do_action('woocommerce_before_shop_loop'); 
      ?> 

      <?php woocommerce_product_loop_start(); ?> 

       <?php woocommerce_product_subcategories(); ?> 

       <?php while (have_posts()) : the_post(); ?> 

        <?php wc_get_template_part('content', 'product'); ?> 

       <?php endwhile; // end of the loop. ?> 

      <?php woocommerce_product_loop_end(); ?> 

      <?php 
       /** 
       * woocommerce_after_shop_loop hook. 
       * 
       * @hooked woocommerce_pagination - 10 
       */ 
       do_action('woocommerce_after_shop_loop'); 
      ?> 

     <?php elseif (! woocommerce_product_subcategories(array('before' => woocommerce_product_loop_start(false), 'after' => woocommerce_product_loop_end(false)))) : ?> 

      <?php wc_get_template('loop/no-products-found.php'); ?> 

     <?php endif; ?> 

    <?php 
     /** 
     * woocommerce_after_main_content hook. 
     * 
     * @hooked woocommerce_output_content_wrapper_end - 10 (outputs closing divs for the content) 
     */ 
     do_action('woocommerce_after_main_content'); 
    ?> 

    <?php 
     /** 
     * woocommerce_sidebar hook. 
     * 
     * @hooked woocommerce_get_sidebar - 10 
     */ 
     do_action('woocommerce_sidebar'); 
    ?> 

<?php get_footer('shop'); ?> 

Jede Hilfe ist sehr geschätzt. Vielen Dank! :)

+0

Sie AJAX benötigen, um Ihre Produkte zu laden, und ein JS-Code, der ausgelöst wird, wenn Sie unten auf der Seite zu bekommen. Sie können [meine Antwort] (http://stackoverflow.com/questions/31587210/load-more-posts-ajax-button-in-wordpress/31588401#31588401) über AJAX laden Beiträge. Ändere es einfach so, dass es Produkte lädt, keine Beiträge und ein Scroll-Ereignis hinzufügt, anstatt zu klicken (mit Js-Code, der prüft, ob du in der Nähe bist). Das [Tutorial] (https://madebydenis.com/ajax-load-posts-on-wordpress/) eignet sich noch besser zum Scrollen ... –

Antwort