• Resolved Bizstudio

    (@ajamm)


    I am just wanting to change the number of categories shown on the homepage to 4. I could make 2 work if I have to.

    Any idea where to do this – looks like it is all via hooks, but cant find where those hooks are drawn from…

Viewing 7 replies - 1 through 7 (of 7 total)
  • Hey, you can use the storefront_product_categories_args filter to manipulate this. See here: https://github.com/woothemes/storefront/blob/master/inc/structure/template-tags.php#L21

    If you don’t want to touch code take a look at our Storefront WooCommerce Customiser extension which allows you to tweak things like this (and much more).

    Thanks.

    Thread Starter Bizstudio

    (@ajamm)

    Thank you – do I need to add the following code to my theme functions?
    Or do I have to replcate and modify that entire file?

    if ( ! function_exists( 'storefront_product_categories' ) ) {
    	/**
    	 * Display Product Categories
    	 * Hooked into the <code>homepage</code> action in the homepage template
    	 * @since  1.0.0
    	 * @return void
    	 */
    	function storefront_product_categories( $args ) {
    		if ( is_woocommerce_activated() ) {
    			$args = apply_filters( 'storefront_product_categories_args', array(
    				'limit' 			=> 3,
    				'columns' 			=> 3,
    				'child_categories' 	=> 0,
    				'orderby' 			=> 'name',
    				'title'				=> __( 'Product Categories', 'storefront' ),
    				) );
    Thread Starter Bizstudio

    (@ajamm)

    Obviously intending to change the quoted code to 4 and 4 for my 4 columns.

    Hi,

    No, you need to filter storefront_product_categories_args.

    So something like;

    add_filter( 'storefront_product_categories_args', 'jk_homepage_category_columns' );
    function jk_homepage_category_columns( $args ) {
    $args['limit'] = 4;
    $args['columns'] = 4;
    return $args
    }

    Make sure you add this to your child theme, not the parent theme.

    Thanks.

    ajamm, i was having asimilar concern. found this snippet:

    function loop_columns() {
    	return 5; // 5 products per row
    }
    add_filter('loop_shop_columns', 'loop_columns', 999);

    on this page: https://docs.woothemes.com/document/change-number-of-products-per-row/

    added that into my child functions.php file and it now allows 5 columns on my product page.

    child-theme
    I am add in functions.php

    wp-content/themes/storefront-child-theme-starter-master/functions.php

    // categories main page 3 to 9
    add_filter( 'storefront_product_categories_args', 'jk_homepage_category_columns' );
    function jk_homepage_category_columns( $args ) {
    	$args['limit'] = 9;
    	$args['columns'] = 3;
    	return $args;
    }

    My site started very slowly loaded.
    Each switching pages – he kept thinking.

    Please tell me the correct code!
    I do not know php.

    knowing8

    (@knowing8)

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Change categorys to 4 not 3’ is closed to new replies.