• Hello,

    I would like to change my Logo per Category.

    For Example:
    – The whole page have the standard logo which I configure on the theme-settings page.
    – All Pages/Posts/Archives etc. in category “xxx” and their child-categories have a different logo.

    I found a snippet, which could do this over the functions.php in the child-theme. I’m not fit in php, so I don’t know, what I have to change in this snippet, so that it works.

    This snippet I found in the support forum:

    add_filter('tc_logo_src', 'my_logo');
    function my_logo($original){
        if (is_category(5) )
            return esc_url( 'YOUR_LOGO_URL');
        else return $original;
    }

    This code is in the Header-File for the logo.

    <!-- .logo -->
    	<div class="logo<?php if( $textlogo = mfn_opts_get('logo-text') ) echo ' text-logo'; ?>">
    	<?php
    	// Logo | Options
    	$logo_options = mfn_opts_get( 'logo-link' ) ? mfn_opts_get( 'logo-link' ) : false;
    	$logo_before = $logo_after = '';
    
    	// Logo | Link
    	if( isset( $logo_options['link'] ) ){
    	$logo_before 	= '<a id="logo" href="'. get_home_url() .'" title="'. get_bloginfo( 'name' ) .'">';
    	$logo_after 	= '</a>';
           } else {
    	$logo_before 	= '<span id="logo">';
    	$logo_after 	= '</span>';
    	}
    
    	// Logo | H1
    	if( is_front_page() ){
    	if( is_array( $logo_options ) && isset( $logo_options['h1-home'] )){
    	$logo_before = '<h1>'. $logo_before;
    	$logo_after .= '</h1>';
    	}
    	} else {
    	if( is_array( $logo_options ) && isset( $logo_options['h1-all'] )){
    	$logo_before = '<h1>'. $logo_before;
    	$logo_after .= '</h1>';
    	}
    	}
    
    	// Logo | Source
    	if( $layoutID = mfn_layout_ID() ){
    
    	$logo_src 		= get_post_meta( $layoutID, 'mfn-post-logo-img', true );
    	$logo_sticky 	= get_post_meta( $layoutID, 'mfn-post-sticky-logo-img', true ) ? get_post_meta( $layoutID, 'mfn-post-sticky-logo-img', true ) : $logo_src;
    	$logo_mobile 	= get_post_meta( $layoutID, 'mfn-post-responsive-logo-img', true ) ? get_post_meta( $layoutID, 'mfn-post-responsive-logo-img', true ) : $logo_src;
    
    	} else {
    
    	$logo_src 		= mfn_opts_get( 'logo-img', THEME_URI .'/images/logo/logo.png' );
    	$logo_sticky 	= mfn_opts_get( 'sticky-logo-img' ) ? mfn_opts_get( 'sticky-logo-img' ) : $logo_src;
    	$logo_mobile 	= mfn_opts_get( 'responsive-logo-img' ) ? mfn_opts_get( 'responsive-logo-img' ) : $logo_src;
    
    	}
    
    	// Logo | SVG width
    	if( $width = mfn_opts_get( 'logo-width' ) ){
    	$width = 'width="'. $width .'"';
    	$class = ' svg';
    	} else {
    	$width = false;
    	$class = false;
    	}
    
    	// Logo | Print
    	echo $logo_before;
    
    	if( $textlogo ){
    
    	echo $textlogo;
    
    	} else {
    
    	echo '<img class="logo-main scale-with-grid'. $class .'" src="'. $logo_src .'" alt="'. mfn_get_attachment_data( $logo_src, 'alt' ) .'" '. $width .'/>';
    	echo '<img class="logo-sticky scale-with-grid'. $class .'" src="'. $logo_sticky .'" alt="'. mfn_get_attachment_data( $logo_sticky, 'alt' ) .'" '. $width .'/>';
    	echo '<img class="logo-mobile scale-with-grid'. $class .'" src="'. $logo_mobile .'" alt="'. mfn_get_attachment_data( $logo_mobile, 'alt' ) .'" '. $width .'/>';
    
    	}
    
    	echo $logo_after;
    	?>
    	</div>

    How can I handle this?

    Kind regards,
    Waldemar

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Different Logos per Category’ is closed to new replies.