• Resolved jennyrrr

    (@jennyrrr)


    Need help to add more than 12 categories on the homepage – (up to 20) I was using a custom plugin for code although this had stopped working and now shows a syntax error. Any help would be appreciated – thank you

    The page I need help with: [log in to see the link]

Viewing 6 replies - 1 through 6 (of 6 total)
  • Job a11n

    (@jobthomas)

    Automattic Happiness Engineer

    Hi @jennyrrr – you would need to use hooks and filters for that. There’s a similar tutorial here on changing the amount of products per page. Using that as a guide, you’d be able to update it.

    Alternatively, you could also add your custom code here and we can have a quick look to see if we can find the syntax error.

    Thread Starter jennyrrr

    (@jennyrrr)

    Hello

    This is the code used:

    add_filter( ‘theme_mod_swc_homepage_category_limit’, ‘wc_ninja_swc_homepage_category_limit’, 25 );
    function wc_ninja_swc_homepage_category_limit() {
    return 20;
    }

    Job a11n

    (@jobthomas)

    Automattic Happiness Engineer

    Hi @jennyrrr – that explains a lot. Did you find this code somewhere else?

    Let me try to clarify: the first part of the add_filter() tells the theme where to drop the custom code. However, ‘theme_mod_swc_homepage_category_limit’ isn’t a location in Storefront but another theme. Just updating it and using the proper Storefront theme locations will do the trick:

    function sf_custom_category_per_page( $args ) {
    	$args['number'] = 20; // Amount of categories to show, no child categories
    	$args['columns'] = 5; // Amount of columns
    	return $args;
    }
    
    add_filter( 'storefront_product_categories_shortcode_args','sf_custom_category_per_page' );
    
    • This reply was modified 6 years, 7 months ago by Job a11n.
    Thread Starter jennyrrr

    (@jennyrrr)

    Thank you, worked a treat.

    Job a11n

    (@jobthomas)

    Automattic Happiness Engineer

    Great to hear that. We’ll mark this thread as resolved now. You can always open a new one.

    You can use the Storefront Powerpack to enable this easily…

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding more than 12 categories on homepage’ is closed to new replies.