0

In wordpress website, we have different categories like Collaboration, Healthcare, Economy etc. I have made separate blogs pages for each category. Required change is if user is on Healthcare blogs page and if he clicks on site-title below the Logo then should takes him to healthcare website homepage. We have another sub-site as Healthcare site. But by default it is going to home site. Blogs are on main site from where I am showing them in Healtcare website.

I have managed to change the site-logo link through code in functions.php But failed to do it for site-title-url.

add_filter( 'get_custom_logo', 'sitelogourl' );

function sitelogourl() {
$category   = get_the_category( $id )[0]->name;
global $post;
$custom_logo_id = get_theme_mod( 'custom_logo' ); 

 if(($post->ID == 3036) || ($category = 'Healthcare')) {
    $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" 
        itemprop="url">%2$s</a>',esc_url( 'https://www.google.com/' ),
        wp_get_attachment_image( $custom_logo_id, 'full', false, array(
            'class'    => 'custom-logo',) ) );
}
else 
    $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" 
        itemprop="url">%2$s</a>',esc_url( 'https://www.yahoo.com' ),
        wp_get_attachment_image( $custom_logo_id, 'full', false, array(
            'class'    => 'custom-logo',) ) ); 
return $html;   

}

  • Site title URL is not handled by get_custom_logo filter. You need to check where that URL is coming from and customize it from child theme. Check header.php for instance. – Nilambar May 16 at 8:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.