[英]How to point wordpress website main logo link to another URL?
I'm using the Flatsome theme and I want the website main logo to point to another link not the homepage, can somebody help me please?我正在使用 Flatsome 主题,我希望网站主徽标指向另一个链接而不是主页,有人可以帮我吗? Here is my header.php
这是我的 header.php
Thank you谢谢
<!DOCTYPE html>
<!--[if IE 9 ]> <html <?php language_attributes(); ?> class="ie9 <?php flatsome_html_classes(); ?>"> <![endif]-->
<!--[if IE 8 ]> <html <?php language_attributes(); ?> class="ie8 <?php flatsome_html_classes(); ?>"> <![endif]-->
<!--[if (gte IE 9)|!(IE)]><!--><html <?php language_attributes(); ?> class="<?php flatsome_html_classes(); ?>"> <!--<![endif]-->
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<link rel="profile" href="http://gmpg.org/xfn/11" />
<link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php do_action( 'flatsome_after_body_open' ); ?>
<?php wp_body_open(); ?>
<a class="skip-link screen-reader-text" href="#main"><?php esc_html_e( 'Skip to content', 'flatsome' ); ?></a>
<div id="wrapper">
<?php do_action( 'flatsome_before_header' ); ?>
<header id="header" class="header <?php flatsome_header_classes(); ?>">
<div class="header-wrapper">
<?php get_template_part( 'template-parts/header/header', 'wrapper' ); ?>
</div>
</header>
<?php do_action( 'flatsome_after_header' ); ?>
<main id="main" class="<?php flatsome_main_classes(); ?>">
Here is what I found in the 'template-parts/header/header, so when I input the link I want it to point to in the home url it takes me to a 404 error page这是我在“模板部分/标头/标头”中找到的内容,所以当我输入链接时,我希望它指向主页 url,它会将我带到 404 错误页面
<!-- Header logo -->
<a href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?><?php echo get_bloginfo( 'name' ) && get_bloginfo( 'description' ) ? ' - ' : ''; ?><?php bloginfo( 'description' ); ?>" rel="home">
<?php if(flatsome_option('site_logo')){
$logo_height = get_theme_mod('header_height',90);
$logo_width = get_theme_mod('logo_width', 200);
$site_title = esc_attr( get_bloginfo( 'name', 'display' ) );
if(get_theme_mod('site_logo_sticky')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.get_theme_mod('site_logo_sticky').'" class="header-logo-sticky" alt="'.$site_title.'"/>';
echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header_logo header-logo" alt="'.$site_title.'"/>';
if(!get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.flatsome_option('site_logo').'" class="header-logo-dark" alt="'.$site_title.'"/>';
if(get_theme_mod('site_logo_dark')) echo '<img width="'.$logo_width.'" height="'.$logo_height.'" src="'.get_theme_mod('site_logo_dark').'" class="header-logo-dark" alt="'.$site_title.'"/>';
} else {
bloginfo( 'name' );
}
?>
</a>
<?php
if(get_theme_mod('site_logo_slogan')){
echo '<p class="logo-tagline">'.get_bloginfo('description').'</p>';
}
?>
You can add below codes in your current active theme's functions.php file and don't forget to change " https://YourAnotherWebsite.com
" with the URL where you want to point.您可以在当前活动主题的 functions.php 文件中添加以下代码,并且不要忘记将“
https://YourAnotherWebsite.com
”更改为您要指向的 URL。
function mrskt_custom_logo_url ( $mrskt_logo_html ) {
$mrskt_custom_logo_id = get_theme_mod( 'custom_logo' );
// Make sure to replace your updated site URL
$mrskt_new_url = 'https://YourAnotherWebsite.com';
$mrskt_logo_html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>',
esc_url( $mrskt_new_url ),
wp_get_attachment_image( $mrskt_custom_logo_id, 'full', false, array(
'class' => 'custom-logo',
) )
);
return $mrskt_logo_html;
}
// get_custom_logo: Returns a custom logo, linked to home unless the theme supports removing the link on the home page.
add_filter( 'get_custom_logo', 'mrskt_custom_logo_url' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.