最近,我需要更改产品排序,以便先查看库存产品,然后查看缺货产品,我在functions.php文件中使用了一个片段:
class iWC_Orderby_Stock_Status
{
public function __construct()
{
// Check if WooCommerce is active
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins')))) {
在存档页面上使用woocommerce时,会有一个包含分页的前商店循环。
分页也包括在商店循环之后,所以我想从页面顶部删除它,并将其留在底部。
这是归档页面代码。从页面顶部删除前商店循环php代码可以正常工作,但会破坏侧边栏的页面格式:
<?php
/** * The Template for displaying product archives, including the main shop page which is a post type archive. * * Override this template by copying it to yourtheme/woocomm
我已经能够使用以下代码片段在最后使用默认排序显示脱销产品: /**
* @snippet Order out of stock products at the end - WooCommerce
* @author Sebastian Velandia
* @compatible WooCommerce 3.8.0
*/
add_filter('posts_clauses', 'order_by_stock_status');
function order_by_stock_status($posts_clauses)