Created
October 10, 2018 19:37
-
-
Save Garconis/2ffbd24b3c84dddf65f595f44df4e614 to your computer and use it in GitHub Desktop.
WooCommerce Products Per Page + Divi
This file contains 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 | |
// help make the plugin of WooCommerce Products Per Page work with the Divi Theme | |
add_action( 'pre_get_posts', 'fs_custom_posts_per_page', 30 ); | |
function fs_custom_posts_per_page( $query = false ) { | |
if ( is_admin() ) return; | |
if ( ! is_a( $query, 'WP_Query' ) || ! $query->is_main_query() ) return; | |
if ( $query->is_category ) { | |
$query->set( 'posts_per_page', apply_filters( 'loop_shop_per_page', 9 ) ); | |
} | |
elseif ( $query->is_tag ) { | |
$query->set( 'posts_per_page', apply_filters( 'loop_shop_per_page', 9 ) ); | |
} | |
elseif ( $query->is_search ) { | |
$query->set( 'posts_per_page', apply_filters( 'loop_shop_per_page', 9 ) ); | |
} | |
elseif ( $query->is_archive ) { | |
$query->set( 'posts_per_page', apply_filters( 'loop_shop_per_page', 9 ) ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment