How to change site-title-url for specific category or page in php?

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;

}

Read more here:: How to change site-title-url for specific category or page in php?

Leave a Reply

Your email address will not be published. Required fields are marked *