【问题标题】:Woocommerce category page missing pagingWoocommerce 类别页面缺少分页
【发布时间】:2013-06-15 06:37:10
【问题描述】:

由于某种原因,产品类别页面中缺少分页。它在所有其他页面上都可以正常工作,而在产品类别页面上却没有。

我扩展了分页模板并在商店页面上正确调用了它,但由于某种原因在类别页面上没有。

谁能说明为什么会这样?

此外,我在此页面上有大约 32 种产品,这足以打破页面记录。

提前致谢。

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    这个问题是因为 post_per_page 查询参数没有在存档页面上设置。

    这可以通过覆盖并将以下代码添加到您的 woocommerce 存档 (archive-product.php) 页面来解决。

    //Will only effect the woocommerce archive page
    global $query_string;
    query_posts($query_string . "&posts_per_page=12");
    

    或者通过在你的主题的functions.php中添加以下内容

     //Will effect both the woocommerce archive page and the wordpress archive page
    function set_row_count_archive($query){
        if ($query->is_archive) {
                $query->set('posts_per_page', 15);
       }
        return $query;
    }
    
    add_filter('pre_get_posts', 'set_row_count_archive');
    

    希望这对某人有所帮助。

    【讨论】:

      猜你喜欢
      • 2016-02-29
      • 1970-01-01
      • 1970-01-01
      • 2020-12-20
      • 1970-01-01
      • 2021-02-07
      • 1970-01-01
      • 2021-11-28
      • 2015-12-19
      相关资源
      最近更新 更多