Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Author HelgaTheViking

    (@helgatheviking)

    Did you add to your template? Or via hook/filter? It doesn’t get added automatically. See the FAQ.

    For default WooCommerce, you can add this to your theme’s functions.php. If you have heavily modified your theme this may not work, but that’s the gist of it.

    function kia_add_subtitle_to_woocommerce(){
    	if( function_exists( 'the_subtitle' ) ) the_subtitle( '<h2 class="subtitle">', '</h2>' );
    }
    add_action( 'woocommerce_template_single_title', 'kia_add_subtitle_to_woocommerce', 7 );
    Thread Starter pathuri

    (@pathuri)

    Did add the code to functions.php.
    But still no display of subtitle on woocommerce pages.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Sorry, it it on the wrong hook:

    function kia_add_subtitle_to_woocommerce(){
        if( function_exists( 'the_subtitle' ) ) the_subtitle( '<h2 class="subtitle">', '</h2>' );
    }
    add_action( 'woocommerce_single_product_summary', 'kia_add_subtitle_to_woocommerce', 7 );
    Thread Starter pathuri

    (@pathuri)

    Added the code, but site crashed.
    Restored after deleting the latest code.
    Seems to be small mistake in the code etc.
    Looks like we are in the right path.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    It is almost 2am where I am, so I could believe a syntax error except I just put this live on my own site so I know it is working. If you were in DEBUG mode you would know what the error was. If you have both code blocks in your functions.php you will crash because you can’t have two functions with the same name.

    Thread Starter pathuri

    (@pathuri)

    Yes! You Are Right!
    It is working fine now.
    Mistake on commenting section for the first code.
    Pl go and have good rest.
    Thank you for Quick Response.
    Just a feature request – if possible to have subtitle multiple rows.

    Plugin Author HelgaTheViking

    (@helgatheviking)

    I’m not sure sure what you mean, but I don’t really have any plans to add new features to the plugin.

    Thread Starter pathuri

    (@pathuri)

    Thanks for all the help.

    gordonlangley

    (@gordonlangley)

    Very helpful – thank you

    Hey there.

    I managed to show the subtitle on my products page, however, it’s not positioned directly under the title.

    I put the code to the functions.php

    Plugin Author HelgaTheViking

    (@helgatheviking)

    If you add it to the correct hook then it will become a link automatically (since WooCommerce has action hooks INSIDE the <a> link tag.

    function kia_add_subtitle_to_woocommerce(){
    	if( function_exists( 'the_subtitle' ) ){
    		the_subtitle( '<h2 class="subtitle">', '</h2>' );
    	}
    }
    add_action( 'woocommerce_shop_loop_item_title', 'kia_add_subtitle_link_to_woocommerce' );

    To make a link somewhere else (in the loop) to you need to the link to the_subtitle() before and after parameters.

    function kia_add_subtitle_link_to_woocommerce(){
    	if( function_exists( 'the_subtitle' ) ){
    
    		$link = the_subtitle( '<h2 class="subtitle"><a href="%s" title="%s">', '</a></h2>', false );
    
    		printf( $link, get_permalink(), sprintf( __( 'Permalink to %s', 'your-text-domain' ), get_the_title() ) );
    
    	}
    }
    add_action( 'some_custom_hook', 'kia_add_subtitle_link_to_woocommerce' );

    Thank you for this feedback. This is working now, so the subtitle is actually a hyperlink to external website.

    The only issue I still have with this is that it’s not placed below the title but under the add to cart button.

    Thanks!

    Plugin Author HelgaTheViking

    (@helgatheviking)

    Code block 1 which should be correct as following:

    function kia_add_subtitle_to_woocommerce(){
    	if( function_exists( 'the_subtitle' ) ){
    		the_subtitle( '<h2 class="subtitle">', '</h2>' );
    	}
    }
    add_action( 'woocommerce_shop_loop_item_title', 'kia_add_subtitle_to_woocommerce' );

    appears directly under the title in default WooCommerce. If it doesn’t then is possible that your theme has modified things and unfortunately I can’t help you with custom theme implementations.

    Thank you. I did use this code actually so it looks like it must be the theme.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘not showing on woocommerce product site’ is closed to new replies.