Tagged: back to top, php
-
AuthorPosts
-
March 21, 2023 at 1:22 am #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,
MichaelMarch 21, 2023 at 6:54 am #1401853Hi 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,
NikkoMarch 21, 2023 at 9:06 am #1401867try 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/
March 21, 2023 at 10:15 am #1401875March 21, 2023 at 11:08 am #1401889The solution @Guenni007 provided works perfectly: https://www.trabitsch.at/locations/
Thanks – Danke Günter! ✌🏻
March 21, 2023 at 11:52 am #1401893Schö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 )
-
AuthorPosts
- You must be logged in to reply to this topic.