• Resolved vishwa1805

    (@vishwa1805)


    Hello, I want to add a video on a specific brand page (archive page).

    I am using the following code. It’s working fine but it’s showing for other categories also.

    add_action( 'woocommerce_archive_description', 'video_on_brand_page', 20 );
    function video_on_brand_page() {
    
    if(has_term( 'vs', 'yith_product_brand' ) ){    
    		  
         echo('<video width="320" height="240" controls>
      <source src="movie.mp4" type="video/mp4">
      <source src="movie.ogg" type="video/ogg">
      Your browser does not support the video tag.
    </video>');
       }
     
    }

    Thank you so much in advice.
    Best regards.

    • This topic was modified 2 years, 2 months ago by vishwa1805.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Juan Coronel

    (@juaancmendez)

    Hello there,

    Yes, sure. In order to achieve what you need, add the following code in the functions.php file of your active child theme:

    if ( ! function_exists( 'video_on_brand_page' ) && class_exists( 'YITH_WCBR' ) ) :
        add_action( 'woocommerce_archive_description', 'video_on_brand_page', 20 );
        function video_on_brand_page() {
            if ( is_tax( YITH_WCBR::get_instance()::$brands_taxonomy ) && 0 === (int) get_query_var( 'paged' ) ) :
                $qo               = get_queried_object();
                $term_id          = $qo->term_id;
                $p_term           = get_term( $term_id, YITH_WCBR::get_instance()::$brands_taxonomy );
                if ( 'adidas' === $p_term->slug ) :
                    echo('<video width="320" height="240" controls>
                        <source src="movie.mp4" type="video/mp4">
                        <source src="movie.ogg" type="video/ogg">
                        Your browser does not support the video tag.
                        </video>');
                endif;
            endif; 
        }
    endif;

    You just have to modify the name of the slug in the line of code << if ( ‘adidas’ === $p_term->slug ) : >> to the one you want.

    Check it out and tell us any news.

    Best regards.

    Thread Starter vishwa1805

    (@vishwa1805)

    Hi Juan,
    Thank you for the response.

    It’s working for me, been trying to solve this for a long time. thank you so much…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to add video or button on specific brand’ is closed to new replies.