Woocommerce get next / previous product SAME category

后端 未结 3 1401
伪装坚强ぢ
伪装坚强ぢ 2021-01-03 12:08

I\'ve read this: Woocommerce get next / previous product

and also tried this:

3条回答
  •  时光取名叫无心
    2021-01-03 12:58

    Example:

    
    
    

    Explanation:

    Using WordPress' previous_post_link or next_post_link will work. In fact, you're almost there.

    In addition to setting true as the third parameter ($in_same_term), make sure to also pass in the taxonomy name as the last parameter ($taxonomy). For WooCommerce, the default product category is product_cat.

    One thing to note, these functions will get next/previous products that match any terms assigned to the current product. Terms can be excluded by passing the term id(s) as the fourth parameter ($exclude_terms).

    Reference:

    https://developer.wordpress.org/reference/functions/previous_post_link/ https://developer.wordpress.org/reference/functions/next_post_link/

    
    
    

提交回复
热议问题