Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Garconis/2ffbd24b3c84dddf65f595f44df4e614 to your computer and use it in GitHub Desktop.
Save Garconis/2ffbd24b3c84dddf65f595f44df4e614 to your computer and use it in GitHub Desktop.
WooCommerce Products Per Page + Divi
<?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