Archived topic
Removing Link on the website logo in primary navigation
19 replies · Started by Jefri on April 7, 2020
Hello,
The website URL is below.
I cannot remove the link on the logo in primary navigation. Is there a way to disable this link (but still have the logo showing)?
Thank you.
Hi there,
Are you still using an old version of GP Premium 1.7.7?
If so can you upgrade to the latest version 1.9.1?
https://docs.generatepress.com/article/updating-gp-premium/
Then remove the navigation logo from Customizer > Primary Navigation.
Then activate this option:
https://docs.generatepress.com/article/navigation-as-a-header/
Then you should get the exact same layout but works better.
After that I can provide the filter to remove the logo link.
Let me know :)
Hello I did this and published it. Thanks.
Can you please tell me how to remove the link on the logo now?
Thanks.
Now try this:
add_filter( 'generate_logo_output', 'tu_no_logo_link', 10, 3 );
function tu_no_logo_link( $output, $logo_url, $html_attr ) {
printf(
'<div class="navigation-branding">
<div class="site-logo">
<img %1$s />
</div>
</div>',
$html_attr
);
}
Adding PHP: https://docs.generatepress.com/article/adding-php/
Hi Leo,
I tried your code and it worked on all pages except my home page (with the transparent header).
On my home page I am using the header element and now the logo is missing only on this page.
Can you please tell me a way to continue to show the logo on the home page?
https://testingmastery.com.au/teacherathome
Thank you.
That's strange, can you remove the function Leo provided so I can take a look at the code?
Hi Tom,
I disabled the code snippet. Thank you.
So now the logo is showing on the home page but the link on the logo image still exists (which I do not want).
Thanks.
Hmm, very weird - that filter isn't used in the Header Element at all.
Let's try this:
add_filter( 'generate_logo_output', function( $output, $logo_url, $html_attr ) {
if ( is_page( 22 ) ) {
return $output;
}
printf(
'<div class="navigation-branding">
<div class="site-logo">
<img %1$s />
</div>
</div>',
$html_attr
);
}, 10, 3 );
Hi Tom, I used the snippet but the problem happened again. The page: https://testingmastery.com.au/teacherathome uses the header elementand the logo disappears.
Can you try the updated code?: https://generatepress.com/forums/topic/removing-link-on-the-website-logo-in-primary-navigation/#post-1233366
Hi Tom,
Thanks, I tried the code. Now on the home page testingmastery.com.au/teacherathome
the logo is showing at the top. However, the link to the home page still exists on this page when you can click on the logo.
The other pages work perfectly (the logo in the navigation does not have a link).
Is there a way I can remove the link on the logo on the page:
testingmastery.com.au/teacherathome ?
Thank you.
Let's try this:
add_filter( 'generate_page_hero_logo_output', function( $output, $logo_url, $html_attr ) {
return sprintf( // WPCS: XSS ok, sanitization ok.
'<div class="site-logo page-hero-logo">
<img %1$s />
</div>',
$html_attr
);
}, 10, 3 );
Let me know :)
Hi Tom,
Thanks. so I put in Both snippets that you provided me.
And now everything is perfect except on the home page https://testingmastery.com.au/teacherathome
the stick navigation logo still has the link attached to it. Can this be removed?
Please note the stick navigation logo does not have a link (which is what I want) on the other pages.
Thanks for your help.
Ah, no filter exists there. I've made a note to add one/make this process more simple.
For now, you can do this:
.navigation-stick .site-logo a {
pointer-events: none;
}