Tagged: ,

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1401839

    Hey guys,

    I would need to customize the anchor link target from Enfold’s “back to top” on one specific page of a website only. The page’s id is 2077 and the link should go to #locations instead of #top.

    I tried following code which did not do the trick:

    add_filter( 'av_back_to_top_href', 'custom_back_to_top_link', 10, 1 );
    
    function custom_back_to_top_link( $href ) {
        // Only modify the link on page with post ID 2077
        if ( is_page( 2077 ) ) {
            // Change the URL to the ID of your custom anchor
            $href = '#locations';
        }
        return $href;
    }

    Any improvement or different solution to that?

    Thx in advance & Best Regards,
    Michael

    #1401853

    Hi Michael,

    The hook you used does not exist so it will not work.
    I think you’ll need to use a child theme and then copy footer.php from the parent theme to the child theme and make changes on line 328:

    <a href='#top' title='<?php _e( 'Scroll to top', 'avia_framework' ); ?>' id='scroll-top-link' <?php echo av_icon_string( 'scrolltop' ); ?>><span class="avia_hidden_link_text"><?php _e( 'Scroll to top', 'avia_framework' ); ?></span></a>

    You can use the conditional tag to set it to change href on page 2077.
    Hope this helps.

    Best regards,
    Nikko

    #1401867

    try in your child-theme functions.php:

    function change_href_from_scroll_top_link(){
    if ( is_page(2077) ) {	
    ?>
    <script type="text/javascript">
    window.addEventListener("DOMContentLoaded", function () { 	
    (function($) {
    	$('#scroll-top-link').attr({
    		'href': 'https://new_link',
    		'title': 'new Title',
    	});
    })(jQuery);
    });
    </script>
    <?php
    }
    }
    add_action('wp_footer', 'change_href_from_scroll_top_link');

    if you got more than one page use array:
    if(is_page(array( 2077, 38147, … ))){

    see test page: https://enfold.webers-webdesign.de/impressum/

    #1401875

    Hi,

    Thanks for helping out @guenni007 :-)

    Best regards,
    Rikard

    #1401889

    The solution @Guenni007 provided works perfectly: https://www.trabitsch.at/locations/

    Thanks – Danke Günter! ✌🏻

    #1401893

    Schön – mach doch noch die letzte Color-Section auch in dem dunklen Blau – der Breite Abstand stört ein wenig. Dann kann man auch den Trenner sehen.

    Der weiße Border kommt dann vom:

    .container_wrap {
      border-top-style: solid;
      border-top-width: 1px;
    }

    den schmeiß ich auch immer direkt raus ( also auf border-top: none )

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