如何在PHP中为特定类别或页面替换site-title-url?

时间:2019-05-16 05:11:03

标签: php wordpress

在wordpress网站中,我们有不同的类别,例如协作,医疗保健,经济等。我为每个类别创建了单独的博客页面。必需的更改是,如果用户位于Healthcare博客页面上,并且单击徽标下方的站点标题,则应将其带到Healthcare网站主页。我们还有另一个子网站作为Healthcare网站。但默认情况下,它将转到主站点。博客在我在Healtcare网站上显示的主要站点上。

我已经设法通过functions.php中的代码更改了站点徽标链接,但是未能对site-title-url进行更改。如何替换/重定向site-title-url 到现有if语句中所需的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;   
}

0 个答案:

没有答案