Created
May 25, 2022 13:25
-
-
Save runezero/82a6c68c2c75fe50fe9f7cdfe89f43aa to your computer and use it in GitHub Desktop.
[Force shop sorting] Set the WooCommerce sorting to a parameter if a parameter is set #woocommerce
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter('woocommerce_default_catalog_orderby', 'default_catalog_orderby'); | |
| function default_catalog_orderby( $sort_by ) { | |
| if(count($_GET) < 1 || isset($_GET['s']) && count($_GET) == 1){ | |
| return 'date'; | |
| } | |
| return $sort_by; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment