I am trying to change the logo link for specific pages, so that it will link to a custom URL for specific page.
I tried to add this code that I found also here in stackoverflow. This works fine on page "169" the logo link point to https://sampleurl.com/page-1/.
//This is for page-1
add_filter('avada_logo_anchor_tag_attributes', 'broadway_logo_link_modify');
function broadway_logo_link_modify() {
$link = esc_url( home_url( '/' ) );
if (is_page( array (169))) {
$link = 'https://sampleurl.com/page-1/';
}
// another option with which you don't have to add every page id
$current_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($current_url, 'https://sampleurl.com/page-1/') !== false) {
$link = 'https://sampleurl.com/page-1/';
}
$link_arr = array(
'class' => 'fusion-logo-link',
'href' => $link,
);
return $link_arr;
}
//This is for page-2
add_filter('avada_logo_anchor_tag_attributes', 'broadway_logo_link_modify');
function broadway_logo_link_modify() {
$link = esc_url( home_url( '/' ) );
if (is_page( array (169))) {
$link = 'https://sampleurl.com/page-2/';
}
// another option with which you don't have to add every page id
$current_url = "http://".$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];
if (strpos($current_url, 'https://sampleurl.com/page-2/') !== false) {
$link = 'https://sampleurl.com/page-2/';
}
$link_arr = array(
'class' => 'fusion-logo-link',
'href' => $link,
);
return $link_arr;
}
I am trying to add the url for /page-2 and /page-3. I added the code again and change the URL to https://sampleurl.com/page-2/ but it broke the site "HTTP Error".
Anyone knows what's the right code to add? Thanks in advance.