Link in Home Block to move to the next Home Block
URL to the page in question:
http://www.attb.nl
-
Dear Bill,
Is there a way to create a link in the content of a Home block that (when clicked) will make the Home page move to display the next Home Block?
Kind Regards,
Jeroen
Hello Jeroen,
Good question there. You can do that. Each section of the home page has a unique ID that you could use to create a link. You’ll need to view the source of your front page to find the IDs to work with.
In the home page of the demo, the first one is #block-9 and the second is #block-14. To link from the first to the second, I would add a link to the content of the first one that has #block-14 as the URL. Make sure to leave out the http:// before the URL.
That should let you add links to the next section.
Have a great weekend,
Bill
Thanks Bill!
I assumed it would be something like that, but I left out the #. Great Help!
Is there a way to make the transition go smooth? Like how the Home Blocks bounce to each other when in between Blocks?
Jeroen
Jeroen,
Glad that helped out. You can try a quick edit to see if the smooth scroll will work here for you. I haven’t tested it with Selfie, but I do use it several of our other themes.
- Go to the Appearance section in your WordPress dashboard and choose Edit.
- From the list of files on your right, choose custom-js.php
- Right before the closing:
</script>
add this:
jQuery(function($) {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top - 0
}, 1000);
return false;
}
}
});
});
- Save your changes.
See if that doesn’t make the scrolling a bit more smooth.
Have a great week,
Bill
Hi Bill,
No need for further testing. Everything works perfect!
Many thanks!
Anytime. Have a great day Jeroen 🙂
- The topic ‘Link in Home Block to move to the next Home Block’ is closed to new replies.