dqu94359 2016-10-03 17:46
浏览 94

将分页添加到Woocommerce自定义模板

Total noob here. I checked all over the net but I'm finding it difficult to add the pagination feature to my homepage. I'm using the recent_products per_page query on my homepage but I want to limit to 12 products so that I can add the infinity scroll option.

<?php get_header(); ?>

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

$args = array(
'post_type' => 'product',
'paged' => $paged,
'posts_per_page' => -1
);
$wp_query = new WP_Query($args);

if (isset($_GET['all']))
{
?>

    <?php do_action('woocommerce_archive_description'); ?>

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

        <?php
        // I don't want the sorting anymore
        //do_action('woocommerce_before_shop_loop');
        ?>

        <ul class = "products-list">
            <?php while (have_posts()) : the_post(); ?>

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

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

        <?php
        /*  woocommerce pagination  */
        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 woocommerce_get_template('loop/no-products-found.php'); ?>

    <?php endif; ?>
    <?php else: ?>
{
    // Code to display the product categories with thumbnails.
}
?>
<?php get_footer(); ?>

Would be great if someone can help me out with this. I need this template or a custom template you suggest to show the same pagination as the shop page (1,2,3) etc..

Thanks.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 关于#hadoop#的问题
    • ¥15 (标签-Python|关键词-socket)
    • ¥15 keil里为什么main.c定义的函数在it.c调用不了
    • ¥50 切换TabTip键盘的输入法
    • ¥15 可否在不同线程中调用封装数据库操作的类
    • ¥15 微带串馈天线阵列每个阵元宽度计算
    • ¥15 keil的map文件中Image component sizes各项意思
    • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
    • ¥15 划分vlan后,链路不通了?
    • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据