• Resolved mariosprt

    (@mariosprt)


    Hello

    First, congrats on a great plugin, probably the best free plugin I’m using right now.

    I have posted this question as reply to a couple of related posts, but I guess this is the right place to do it, so excuse the repetition.

    Basically I wanted to change the brand page, replacing the title with the logo.
    I found this bit of code that I put in the functions.php file:

    add_filter(‘woocommerce_show_page_title’, function(){
    if (is_tax( ‘pwb-brand’ )) {
    echo ‘<div>put brand logo here</div>’;
    }
    } );

    This successfully allows me to remove the title, now I just need to call the logo in here.

    Can you help me?
    Thanks
    Mario

Viewing 1 replies (of 1 total)
  • Thread Starter mariosprt

    (@mariosprt)

    I found a way to do it, using this code in the functions.php.
    If inside a Brand page, it gets the slug of the page, then it cycles through all brands and compares the slug of the current page with each brand, if the finds a match, it shows the logo for that brand.
    It’s not the most efficient way to do it, having to cycle all the brands, but it works.

    add_filter('woocommerce_show_page_title', function(){
    	if (is_tax( 'pwb-brand' )) {
    		global $wp;
    		$request = $wp->request.'/';
    		$terms = get_terms('pwb-brand'); 
    		foreach ( $terms as $term ) { 
    			$brand_link = get_term_link($term->term_taxonomy_id);
    			$thumbnail_id = get_term_meta( $term->term_taxonomy_id, 'pwb_brand_image', true );
    			$image = wp_get_attachment_url( $thumbnail_id );
    			$brand_link = str_replace(esc_url( home_url( '/' ) ), '', $brand_link);
    			if($brand_link==$request)
    			{
    				?>
    				<img />" width="150" />
    				<?php
    			}
    		}
        }
    } );
    • This reply was modified 6 years, 7 months ago by mariosprt.
    • This reply was modified 6 years, 7 months ago by mariosprt.
Viewing 1 replies (of 1 total)
  • The topic ‘Replace title with logo in brand page’ is closed to new replies.