• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How to make whole home page link able ?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › How to make whole home page link able ?

This topic is: not resolved
  • This topic has 4 replies, 3 voices, and was last updated 6 years, 9 months ago by wparrow.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • May 23, 2016 at 1:31 am #186116
    wparrow
    Member

    Hi,
    I just setup a WordPress blog and installed Genesis and child theme
    How ever I would like to make my whole home page link able.

    This mean, whole home page is the hyper link. when visitor click any where on the home page, the new page will open and current home page will redirect to affiliate site.
    The code is: `<a href="newpage-open-in-new-window.html" onclick="location.href='http://www.affiliateurlhere.com';" rel="nofollow" target="_blank" style="text-decoration: none; color: #222;">
    HOME PAGE
    </a>`

    I see the code above worked for HTML site but I want it work on Genesis site also.

    Please help
    Thanks

    June 3, 2016 at 10:45 pm #186924
    chrismcintosh
    Member

    Something like the following would probably work.

    Add it to your functions.php or more specifically your front page.

    You are essentially using one of the earliest on page hooks and the latest to encapsulate the rest of the content.

    
    <?php
    
    add_action('genesis_before', 'cm_open_anchor');
    function cm_open_anchor() {
    echo '<a href="#">';
    }
    
    add_action('genesis_after', 'cm_close_anchor');
    function cm_close_anchor() {
    echo '</a>';
    }
    
    June 3, 2016 at 11:00 pm #186927
    wparrow
    Member

    Thanks chrismcintosh for your help but your code doesn't has the onclick function?

    The code from above will open new window when user click any where on the home page, then current home page will redirect to affiliate link.

    You code seem only open one url

    June 4, 2016 at 4:47 am #186934
    Victor Font
    Moderator

    The code above is a starter point. Modify the code yourself to add the onlick function to the anchor link. You've already provided the example, just copy and paste your example into the code snippet to use it.

    add_action('genesis_before', 'cm_open_anchor');
    function cm_open_anchor() {
    $location = "http://www.affiliateurlhere.com";
    echo '<a href="newpage-open-in-new-window.html" onclick="location.href=' . $location . ';" rel="nofollow" target="_blank" style="text-decoration: none; color: #222;">';
    }

    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    June 4, 2016 at 6:00 am #186937
    wparrow
    Member

    Thanks Victor Font for full of code

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble