Support » Plugin: WooCommerce Products Per Page » Can't get it working!

Viewing 15 replies - 1 through 15 (of 25 total)
  • Plugin Author Jeroen Sormani

    (@sormano)

    Hi Gasto,

    Strange it does not work. I see that the .products class is falling over the dropdown, you can fix this by adding .products { float: left } to your css.

    Can you try to add the minimal code to your functions.php:

    function shop_columns_hook() {
    	return 10;
    }
    add_filter( 'loop_shop_per_page', 'shop_columns_hook', 90 );

    Maybe up the ’90’ more, like to hear your findings…

    gasto

    (@gasto)

    Thanks for the answer, with .products { float: left } the dropdown is finally working, but I always get all the products on the same page, no matter what I chose on the dropdown menu, even with that code on functions.php

    In case it’s important, here’s what’s already on my functions.php:

    /**
     * remove on single product panel, "Product Description"
     * since it already says "Description" on tab.
     */
    add_filter('woocommerce_product_description_heading',
    'isa_product_description_heading');
    
    function isa_product_description_heading() {
        echo '';
    }
    
    remove_action( 'woocommerce_product_tabs', 'woocommerce_product_description_tab', 10 );
    remove_action( 'woocommerce_product_tab_panels', 'woocommerce_product_description_panel', 10 );
    
    remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
    
    /** Remove Showing results functionality site-wide */
    function woocommerce_result_count() {
            return;
    }
    
    remove_action( 'woocommerce_before_shop_loop', 'woocommerce_catalog_ordering', 30 );
    
    remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
    
    function shop_columns_hook() {
    	return 10;
    }
    add_filter( 'loop_shop_per_page', 'shop_columns_hook', 90 );
    Plugin Author Jeroen Sormani

    (@sormano)

    Hi,

    Your functions.php looks good further.

    If its a woothems theme there’s a good chanche there might be an theme option for it.

    Otherwise you can try to set the ’90’ to ’99’ or ‘900’ or so and try that.

    Another try you can do is set the ‘Blog pages show at most’ on the settings -> reading page to the desired amount.

    gasto

    (@gasto)

    Thanks for replying.
    “Blog pages shown at most” is set to 10.
    There’s an option on wootheme settings that says “Products per page” and “Products columns”. Products per page is set to 10, and columns is set to 5, this last setting seems to work OK, because I change it to whatever other value and it changes just fine. But products per page is not working whatever value I choose…

    I’ve tried any value on the functions.php code you gave me, 10 or 150 or 1742, it’s always the same….

    If you want I can give you access to my wordpress admin page.

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi Gasto,

    Give me an mail via my website.

    John

    (@logicallabs)

    This is not working for me either.

    An interesting note is that I first installed another plugin, WooCommerce Product Archive Customiser, and it is supposed to handle “products per page” also and it also did not work. I disabled it before I tried installing this one.

    Perhaps there is a change in a recent version of WooCommerce that is causing both plugins to fail?

    Maybe its another plugin I have that is causing both plugins to fail?

    Any ideas?

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi logicallabs,

    I’ve had contact with gasto, and seemed to me there was something with his theme (superstore (woothemes)).
    I even woocommerce hard coded a different amount of products per page, but nothing seemed to help..

    He is going to (or already has) contact woothemes to see if they know why/how.

    What theme do you use?

    John

    (@logicallabs)

    I am using the Divi theme from ElegantThemes.

    John

    (@logicallabs)

    I’ve attempted to poke around a little at this, as a inexperienced WordPress developer, and I pushed some buttons and things started happening.. but not certain I’ve determined a solution yet.

    I noticed that not only is this plugin not affecting the posts per page, but also the main Settings > Reading post number values have no affect either.

    I went into the Divi theme’s “custom_functions.php” and found this

    add_action( 'pre_get_posts', 'et_custom_posts_per_page' );
    function et_custom_posts_per_page( $query = false ) {
    	global $shortname;
    
    	if ( is_admin() ) return;
    
    	if ( ! is_a( $query, 'WP_Query' ) || ! $query->is_main_query() ) return;
    
    	if ( $query->is_category ) {
    		$query->set( 'posts_per_page', (int) et_get_option( $shortname . '_catnum_posts', '10' ) );
    	} elseif ( $query->is_tag ) {
    		$query->set( 'posts_per_page', (int) et_get_option( $shortname . '_tagnum_posts', '10' ) );
    	} elseif ( $query->is_search ) {
    		if ( isset($_GET['et_searchform_submit']) ) {
    			$postTypes = array();
    			if ( !isset($_GET['et-inc-posts']) && !isset($_GET['et-inc-pages']) ) $postTypes = array('post');
    			if ( isset($_GET['et-inc-pages']) ) $postTypes = array('page');
    			if ( isset($_GET['et-inc-posts']) ) $postTypes[] = 'post';
    			$query->set( 'post_type', $postTypes );
    
    			if ( isset( $_GET['et-month-choice'] ) && $_GET['et-month-choice'] != 'no-choice' ) {
    				$et_year = substr($_GET['et-month-choice'],0,4);
    				$et_month = substr($_GET['et-month-choice'], 4, strlen($_GET['et-month-choice'])-4);
    
    				$query->set( 'year', absint($et_year) );
    				$query->set( 'monthnum', absint($et_month) );
    			}
    
    			if ( isset( $_GET['et-cat'] ) && $_GET['et-cat'] != 0 )
    				$query->set( 'cat', absint($_GET['et-cat']) );
    		}
    		$query->set( 'posts_per_page', (int) et_get_option( $shortname . '_searchnum_posts', '10' ) );
    	} elseif ( $query->is_archive ) {
    		$query->set( 'posts_per_page', (int) et_get_option( $shortname . '_archivenum_posts', '10' ) );
    	}
    }

    I modified the function to immediately execute this

    $query->set( 'posts_per_page', '6' );
    	return;

    and now I see 6 products in my page.

    This doesn’t tell me why the other settings and the plugin values are being ignored (and they still are being ignored) but it did seem to change things …

    I am not sure if this is completely useless information for trying to solve this problem but thought I would share before I call it a night.

    Hopefully this can be fixed.

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi John,

    The code you posted definitely causes the plugin (and other code) some trouble. Seems like the code is not WooCommerce related, but meant for general posts.

    You could do several things when you use a child theme of Divi:
    1. Add a filter to this function

    $query->set( 'posts_per_page', apply_filters( 'loop_shop_per_page', '6' ) );

    2. Make a if check, placed at the add_action, or within the function

    if ( 'product' == get_post_type() ) return;

    3. Delete the posted code (if unused and legal)
    4. Create a new function and place it in your functions.php

    add_action( 'pre_get_posts', 'wppp_extra_filter', 30 );
    function wppp_extra_filter( $query = false ) {
        $query->set( 'posts_per_page', apply_filters( 'loop_shop_per_page', 12 ) );
    }

    *All code above is untested, but is a solid basis.

    I will reconsider what will be the best method for the plugin to use.

    Let me know if this helped you out 🙂

    John

    (@logicallabs)

    I tried your suggestion 4 and it did appear to change the fact that before I was only seeing some partial list (I have 8 products and I was only seeing 5 before) – so the obscure 5 limit is gone now. Now I see all 8 on one page. However, returning to be able to control products per page (i.e. changing it to 4) or trying to change the columns per page (i.e changing it to 2) still has no affect (either change). I am baffled.

    Plugin Author Jeroen Sormani

    (@sormano)

    Hi John,

    Could you contact me by my website? I would like to have a look at the code, and try to find a solid fix for you and gasto.

    Thnx

    Plugin Author Jeroen Sormani

    (@sormano)

    Hey John,

    Have not received an message. Did you (or gasto) already figure this out?

    Let me know, thnx!

    John

    (@logicallabs)

    Sormano, How do you want me to contact you?

    Plugin Author Jeroen Sormani

    (@sormano)

Viewing 15 replies - 1 through 15 (of 25 total)
  • The topic ‘Can't get it working!’ is closed to new replies.