[Resolved] Add link to header image?

Home Forums Support [Resolved] Add link to header image?

Home Forums Support Add link to header image?

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #59638
    _blank

    Site is http://3de.48c.myftpupload.com/
    WordPress 4.1
    GeneratePress 1.2.4

    I’ve added a Header image to my site (so that it appears on all pages) using the Background Images Add-on that came with my purchase of GP Premium. I need to have this header image link to a page within the site. Is this possible?

    #59767
    _blank

    I also notice that the header image is not responsive. Is there a better way to add a header image and have it be responsive and linkable?

    #59924
    Tom
    Lead Developer
    Lead Developer

    Hi Art,

    For a header image like that, you’re better of using the “Customize > Header Content” section and upload it as a logo.

    Let me know if that works ๐Ÿ™‚

    #60184
    _blank

    OK, that works! TY

    btwโ€ฆ

    I added cssโ€ฆ
    /* tighten space around header image if image is placed using Customize > Header Content */
    .inside-header {
    padding: 0px;
    }

    and edited the link in the theme’s header.php to make the header image link to a page in the site other than the home page. (be aware that GeneratePress theme updates may overwrite the edit done to header.php)

    If there’s a better way to do the link change, please let me know.

    #60248
    Tom
    Lead Developer
    Lead Developer

    You would be better off using a child theme, and copying the header.php file over to your child theme folder. This way, your changes won’t be lost when you update.

    However, you’ll also miss out on any changes I make to header.php.

    I just went ahead and added a filter to the href of the logo, so once 1.2.5 is released, you can use a snippet of PHP to change the URL without modifying any core files.

    It would work like this (Note: This will not work until GeneratePress 1.2.5 is released).

    add_filter( 'generate_logo_href','generate_add_custom_logo_href' );
    function generate_add_custom_logo_href()
    {
          return 'http://yourcustomlogohref.com';
    }
    • This reply was modified 8 years, 1 month ago by Tom.
    #145245
    Markus

    Hi Tom,

    somehow I did not manage to REMOVE any link from the header image.

    How do I go about that?

    Best wishes,
    Markus

    #145318
    Tom
    Lead Developer
    Lead Developer

    To remove the link, I would remove the logo from the Customizer.

    Then using GP Hooks, add your logo using the “Before Header Content” hook.

    <div class="site-logo">
        <img class="header-image" src="THE URL TO YOUR LOGO" alt="YOUR WEBSITE NAME" />
    </div>
    #145402
    Markus

    Thanks! It worked, of course ๐Ÿ˜‰

    All best,
    Markus

    #145413
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

    #178525
    Rachel

    Where should I insert this code within the header.php?

    It would work like this (Note: This will not work until GeneratePress 1.2.5 is released).

    function generate_add_custom_logo_href()
    {
    return ‘http://yourcustomlogohref.com&#8217;;
    }

    #178538
    Tom
    Lead Developer
    Lead Developer
    #178615
    Rachel

    Hi Tom,
    I created a plugin using your code with my href page name:

    <?php
    function generate_add_custom_logo_href()
    {return ‘http://www.actonrecovery.com/rachel-shaw-bio/&#8217;;}
    ?>

    When clicking on the header logo image, it returns me to my home page. What did I do wrong?

    #178658
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    I just adjusted the code: https://generatepress.com/forums/topic/add-link-to-header-image/#post-60248

    Let me know if it works or not ๐Ÿ™‚

    #178735
    Rachel

    Thanks Tom,
    The additional line worked

    #178756
    Tom
    Lead Developer
    Lead Developer

    You’re welcome ๐Ÿ™‚

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.