Jump to content

where to place code function.php or custom.css


Recommended Posts

Woocommerce took out the option for enabling a lightbox feature for your image gallery earlier this year.  They have in their documentation to add code if you want to enable the gallery features but don’t actually say where.


This is a significant frontend change that can be broken down in to three separate new features;

  • Image zoom / magnification

  • Lightbox

  • Slider

To enable each of these features in your theme you must declare support using add_theme_support() like so;








add_action( 'after_setup_theme', 'yourtheme_setup' );


function yourtheme_setup() {

    add_theme_support( 'wc-product-gallery-zoom' );

    add_theme_support( 'wc-product-gallery-lightbox' );

    add_theme_support( 'wc-product-gallery-slider' );


This allows you the flexibility to pick and choose exactly which features you want to include/exclude in your theme or at your store.

I am not a developer, I don’t have a developer (and shame on WC for not making this an option that end users can opt for or not without having to add code!)  I need to know where to put this code.  I am using a child theme called mystile1.  I have files called “Theme Functions (function.php)” and one called “custom.css” that’s says it is specifically for adding code to modify my child theme styles.

I don’t know which file I should put the above coding in and where.  Nowhere does each of these files have a line called “after_setup_theme” So would I be safe in just adding the code as follows in one of those files (which one?) replacing “yourtheme” with the name of my theme:

add_action( 'after_setup_theme', 'mystile1_setup' );


function mystile1_setup() {

    add_theme_support( 'wc-product-gallery-zoom' );

    add_theme_support( 'wc-product-gallery-lightbox' );

    add_theme_support( 'wc-product-gallery-slider' );



Or any other suggestions are greatly appreciated.

Thank you.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...