在 Woocommerce 中自定义我的帐户订单列表每页帖子 [英] Customizing My Account Orders list post per page in Woocommerce

查看:56
本文介绍了在 Woocommerce 中自定义我的帐户订单列表每页帖子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Woocommerce 2.6.x 在用户帐户(我的帐户)区域有一个特殊页面,显示用户以前的订单.

Woocommerce 2.6.x has a special page at the user account (My Account) area where it displays the user's previous Orders.

此页面现在已分页,默认显示为每页 15 个项目.

This page is now paginated and it displays as default 15 items/page.

这里是woocommerce店面主题Orders区域的8行截图:

Here the screenshot of the woocommerce storefront theme Orders area with 8 lines:

我找不到改变它的方法.

I Can't find the way to change this.

如何只显示 7 个项目而不是默认数量?

How can I show only 7 items instead of the default number?

谢谢.

推荐答案

使用 woocommerce_my_account_my_orders_query 钩子中的自定义钩子函数,您可以更改订单查询,自定义 post_per_page 参数7,随心所欲.

这是代码:

add_filter( 'woocommerce_my_account_my_orders_query', 'custom_my_account_orders', 10, 1 );
function custom_my_account_orders( $args ) {

    $args['posts_per_page'] = 7;
    return $args;
}

对于 woocommerce 3+ 使用 limit 代替:

For woocommerce 3+ use limit instead:

add_filter( 'woocommerce_my_account_my_orders_query', 'custom_my_account_orders', 10, 1 );
function custom_my_account_orders( $args ) {
    // Set the post per page
    $args['limit'] = 7;

    return $args;
}

代码位于活动子主题(或活动主题)的 function.php 文件中.经过测试并有效.

注意:通常在我的帐户页面中显示订单列表时,店面主题和其他主题的默认值为 10 (但不是 15).

Note: Normally the default value for storefront theme and other themes too when displaying the list of orders in my account pages is 10 (but not 15).

这篇关于在 Woocommerce 中自定义我的帐户订单列表每页帖子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆