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

时间:2016-10-03 17:46:40

标签: php wordpress pagination woocommerce

这里的总菜鸟。我在网上查了一下,但我发现很难在我的主页上添加分页功能。我正在使用 recent_products per_page 查询我的主页,但我想限制为12个产品,以便我可以添加无限滚动选项。

<?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(); ?>

如果有人可以帮我解决这个问题会很棒。我需要这个模板或你建议的自定义模板,以显示与商店页面(1,2,3)相同的分页。

感谢。

0 个答案:

没有答案
相关问题