• I’m looking at my Single Product title template:

    the_title( '<h1 class="product_title entry-title">', '</h1>' );
    And I want to add a class (‘small’) to the title without modifying the template (to avoid problems with future updates).

    I’d like to plop in a filter but don’t know how to do this. I suspect it’s something like this:

      add_filter( 'woocommerce_product_loop_title_classes', 'custom_woocommerce_product_title_classes' );
        
        function custom_woocommerce_product_title_classes( $class ) {
            return $class . ' small'; 
        }

    Which seems to work for the shop page, but not the single product page.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support RK a11n

    (@riaanknoetze)

    Hi there,

    Just to make sure – Why are you looking to add HTML markup affecting the size rather than adding custom CSS for that in your WordPress settings under **Appearance > Customize > Additional CSS** (or in a child theme)?

    Thread Starter CactusWren

    (@migueldemaria)

    Thanks for the reply, @riaanknoetze . I’m using Bootstrap and prefer to use its built-in classes instead of overriding them. But I will use CSS if I that doesn’t work out.

    I am working with a child theme (of WP-Bootstrap-Starter).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Filter/hook to add class to h1 on single-product.php’ is closed to new replies.