[Resolved] Removing Link on the website logo in primary navigation

Home Forums Support [Resolved] Removing Link on the website logo in primary navigation

Home Forums Support Removing Link on the website logo in primary navigation

Viewing 15 posts - 1 through 15 (of 20 total)
  • Author
    Posts
  • #1230588
    Jefri

    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.

    #1230622
    Leo
    Staff
    Customer Support

    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 ๐Ÿ™‚

    #1230714
    Jefri

    Hello I did this and published it. Thanks.

    Can you please tell me how to remove the link on the logo now?

    Thanks.

    #1231575
    Leo
    Staff
    Customer Support

    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/

    #1231941
    Jefri

    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.

    #1232827
    Tom
    Lead Developer
    Lead Developer

    That’s strange, can you remove the function Leo provided so I can take a look at the code?

    #1233345
    Jefri

    Hi Tom,

    I disabled the code snippet. Thank you.

    #1233347
    Jefri

    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.

    #1233366
    Tom
    Lead Developer
    Lead Developer

    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 );
    #1233422
    Jefri

    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.

    #1234224
    Tom
    Lead Developer
    Lead Developer
    #1234828
    Jefri

    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.

    #1235457
    Tom
    Lead Developer
    Lead Developer

    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 ๐Ÿ™‚

    #1235769
    Jefri

    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.

    #1236375
    Tom
    Lead Developer
    Lead Developer

    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;
    }
Viewing 15 posts - 1 through 15 (of 20 total)
  • You must be logged in to reply to this topic.