• 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

GoToTop link

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 › GoToTop link

This topic is: resolved
  • This topic has 6 replies, 2 voices, and was last updated 13 years, 3 months ago by marjwyatt.
Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • April 8, 2013 at 1:21 pm #34059
    marjwyatt
    Member

    I've finally noticed that the GoToTop link in the Genesis framework leads to http://yourdomainname.com/#wrap, where the site url varies with the actual domain name.  With headers of lesser height, this returns the link clicker to a point where part of the header is obfuscated by the wpadmin bar (if logged in).

    I'm not a fan of really tall header spaces because, in my humble opinion, they consume too much of the vertical height of the page and I build a lot of membership sites for my clients so this is becoming a bother.

    This is the code that is adding #wrap to the href link, found in the genesis shortcodes folder:
    <code>

    add_shortcode( 'footer_backtotop', 'genesis_footer_backtotop_shortcode' );
    /**
    * Produces the "Return to Top" link.
    *
    * Supported shortcode attributes are:
    * after (output after link, default is empty string),
    * before (output before link, default is empty string),
    * href (link url, default is fragment identifier '#wrap'),
    * nofollow (boolean for whether to make the link include the rel="nofollow"
    * attribute. Default is true),
    * text (Link text, default is 'Return to top of page').
    *
    * Output passes through 'genesis_footer_backtotop_shortcode' filter before returning.
    *
    * @since 1.1.0
    *
    * @param array $atts Shortcode attributes
    * @return string Shortcode output
    */
    function genesis_footer_backtotop_shortcode( $atts ) {
    $defaults = array(
    'after' => '',
    'before' => '',
    'href' => '#wrap',
    'nofollow' => true,
    'text' => __( 'Return to top of page', 'genesis' ),
    );
    $atts = shortcode_atts( $defaults, $atts );
    $nofollow = $atts['nofollow'] ? 'rel="nofollow"' : '';
    $output = sprintf( '%s<a href="%s" %s>%s</a>%s', $atts['before'], esc_url( $atts['href'] ), $nofollow, $atts['text'], $atts['after'] );
    return apply_filters( 'genesis_footer_backtotop_shortcode', $output, $atts );
    }</code>

    I see it is a default for that output.  What is the best method for filtering that link to make it be href # instead of href #wrap?


    Virtually Marj Wyatt
    VirtuallyMarj.com | Twitter | Facebook | Google +

    April 9, 2013 at 10:09 am #34282
    surefirewebserv
    Member

    No need to change that, that's the actual code that creates the short code, but the short code already has the href attribute in place: [footer_backtotop text="Top" href="#content"]

    You can change it to anything you want.

    Here's the filter to change what the default is:

    add_filter( 'genesis_footer_backtotop_text', 'custom_footer_backtotop_text' );
    function custom_footer_backtotop_text($backtotop) {
    	$backtotop = '[footer_backtotop text="Return to Top" href="#content"]';
    	return $backtotop;
    }

    That should work.


    SureFireWebServices.com | Genesis Tuts and More
    Genesis Theme Starter Kit | It’s Free

    April 9, 2013 at 11:05 am #34294
    marjwyatt
    Member

    Thanks for the suggestion but it didn't work for me.  In fact, that code makes the link to the top not work at all.


    Virtually Marj Wyatt
    VirtuallyMarj.com | Twitter | Facebook | Google +

    April 9, 2013 at 11:21 am #34301
    surefirewebserv
    Member

    That code works, just tested it. Did you put it in the functions.php file? Did you change #content to where you want the back to top to go? Are you using a child theme?

    You can copy this verbatim

    add_filter( 'genesis_footer_backtotop_text', 'custom_footer_backtotop_text' );
    function custom_footer_backtotop_text($backtotop) {
        $backtotop = '[footer_backtotop text="Return to Top" href="#"]';
        return $backtotop;
    }

    An alternate solution would be to download the genesis simple edits plugin and edit the footer info using the back to top shortcode with href="#"

    [footer_backtotop text="Top" href="#"]

    More information on the shortcodes are found here: http://my.studiopress.com/docs/shortcode-reference/#footer-backtotop-shortcode


    SureFireWebServices.com | Genesis Tuts and More
    Genesis Theme Starter Kit | It’s Free

    April 9, 2013 at 12:17 pm #34308
    marjwyatt
    Member

    An alternate solution would be to download the genesis simple edits plugin and edit the footer info using the back to top shortcode with href=”#”

     

    I'm really not a big fan of adding plugins to any site for such a simple issue.  The second idea you suggest did work.  I had tried that next and just hadn't gotten back her to update the thread as being resolved.

    Where do I post a suggestion that this shortcode be changed in the framework itself.  It seems "wrong" to have it go to #wrap in the first place, to me.


    Virtually Marj Wyatt
    VirtuallyMarj.com | Twitter | Facebook | Google +

    April 9, 2013 at 12:54 pm #34320
    surefirewebserv
    Member

    Well I wouldn't necessarily say that it's wrong, #wrap is the first tag on the top of the site, it only seems like the issue you're seeing is when someone is logged in and the admin bar is being displayed. There are ways around that, simply turning the admin bar off on the front end would fix it.

    In any case, the short code and filter I provided allows you to change it to go wherever you want, so the flexibility to change it is there, and that's what really matters.

    It's just a matter of preference.


    SureFireWebServices.com | Genesis Tuts and More
    Genesis Theme Starter Kit | It’s Free

    April 9, 2013 at 1:33 pm #34329
    marjwyatt
    Member

    @surefirewebserv ... thanks again for your suggestions.  The one that finally worked was discovered by me prior to your suggestion, however.  I just hadn't found the Genesis tutorial that indicated we could change the href destination within the code that alters the backtotop text.

    As for the workaround of turning off the admin bar, of course I'm aware of that.  I did mention that I am building a lot of membership sites, right?  For those memberships, I am authoring code that gives the members perpetual access to the links they need on the site, like the members home portal, etc.  To that end, turning off the admin bar is counterproductive.

    To my way of thinking, the top of the page is the top of the page, not the top of the wrap for that page.  So, we will have to agree to disagree on whether or not # is preferred over #wrap.  In my opinion, it is not. and I will alter this filter on every custom theme that I write going forward, until the Genesis Framework makes a change.


    Virtually Marj Wyatt
    VirtuallyMarj.com | Twitter | Facebook | Google +

  • Author
    Posts
Viewing 7 posts - 1 through 7 (of 7 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

© 2026 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