Last active
September 5, 2022 11:07
-
-
Save pramodjodhani/f0ffa5836f0a6963bd904e7c0127ef7f to your computer and use it in GitHub Desktop.
Orderable - Fix issue where addons are not working for some product.
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 | |
| /** | |
| * Orderable - Fix issue where addons are not working for some product. | |
| * This issue happens because by default for performance reasons, | |
| * orderable only loads the first 100 product addons posts (orderable_addons) | |
| * This snippet would force load 500 addons. | |
| * | |
| * @param WP_Query $q Query. | |
| * | |
| * @return void | |
| */ | |
| function orderable_fix_increase_addons_limit( $q ) { | |
| $post_type = $q->get( 'post_type' ); | |
| if ( 'orderable_addons' === $post_type && 100 == $q->get( 'posts_per_page' ) ) { | |
| $q->set( 'posts_per_page', 500 ); | |
| } | |
| } | |
| add_action( 'pre_get_posts', 'orderable_fix_increase_addons_limit' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment