Created
September 26, 2017 03:36
-
-
Save msaari/3c8c3e840dbacf35df0fd52e4f414c7a to your computer and use it in GitHub Desktop.
Set "include_children" to false for "product_cat" taxonomy queries
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
| <?php | |
| // Add this to theme functions.php | |
| add_filter('relevanssi_modify_wp_query', 'rlv_modify_query'); | |
| function rlv_modify_query($query) { | |
| for ($i = 0; $i < count($query->tax_query->queries); $i++) { | |
| if (isset($query->tax_query->queries[$i])) { | |
| $row = $query->tax_query->queries[$i]; | |
| if (isset($row['taxonomy']) && $row['taxonomy'] == "product_cat") { | |
| $row['include_children'] = false; | |
| $query->tax_query->queries[$i] = $row; | |
| } | |
| } | |
| } | |
| return $query; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment