我需要更改默认WordPressget_custom_logo()
生成url,因为我需要链接到主多站点站点而不是单个站点。是否有任何过滤器可以更改此功能?
如何更改GET_CUSTOM_LOGO()url?
2 个回复
SO网友:Davide De Maestri
我使用此过滤器解决了以下问题:
add_filter( \'get_custom_logo\', \'custom_logo_url\' );
function custom_logo_url ( $html ) {
$custom_logo_id = get_theme_mod( \'custom_logo\' );
$url = network_site_url();
$html = sprintf( \'<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>\',
esc_url( $url ),
wp_get_attachment_image( $custom_logo_id, \'full\', false, array(
\'class\' => \'custom-logo\',
) )
);
return $html;
}
SO网友:Nefeline
以下是另一种解决方案:
function update_logo_url( $html ) {
$site_url = get_site_url();
return str_replace( $site_url, esc_url( \'https://your.url\' ), $html );
}
add_filter( \'get_custom_logo\', \'update_logo_url\' );