February 26, 201412 yr Hello all. I am having a problem with my anchor tags on a site I am working on. They work fine when you load the page up first time and link to the relevant sections correctly. The problem happens once you click on the Blog link. Once you click on the Blog link in the header and click on a post, the sticky nav is not working correctly. If you then click on another link in the header to take you back to that section, it does not jump to the top of the section like it does when first load the page. The page jumps to a point which is below the top of the section. You can view the site here. I'm not sure why the anchor tag is behaving like this because once you click on another link it works fine. It only does not work when you are trying to link back from a blog post. Can anyone help with this problem?
February 27, 201412 yr Hi , it's because all links are navigating you on the main page without reloading the site just scrolling on the index (index.php) to clicked categories. But once you click on a blog post it will open a new page (I'm not sure but I think it's post.php) on your site . After clicking back on other link pointing to index.php#something the browser is trying to find #something-point on your site but it's not fully loaded so #something is not found , that's why it keeps you on top of the page. However I'm using chrome33 and after couple of seconds (until site loads) it will scroll to clicked section. I think it's not working in all browsers like it is in chrome. I hope u can understand me and it helped
February 27, 201412 yr Author Thanks for your reply. Do you know of a way I can get it to jump to the correct section? I have tried to create a div above the section with an anchor link, but this does not work either. I'm not sure how I can get it to work like on the homepage. Can anyone help?
February 27, 201412 yr To make anchors that jump you need to use the following. <a href="#name">Jump to Name</a> And then you can use this. <a name="name"></a> Good luck!
February 27, 201412 yr Author Thanks for your reply. That is what I have tried, but it did not work. In my header.php file I have the following: <a href=" <?php echo get_site_url(); ?>#abouthome" title="" style="background:#585fad;"> About </a> Then in the backend of Wordpress at the top of the About page I have the following: <a name="abouthome"> </a> This does not seem to work as the link jumps to the section, but not at the correct point. It jumps below the anchor so that the section header is not shown.
February 28, 201412 yr You just need to move the <a name="abouthome"></a> up a bit, I usually put it 2-3 lines higher in the page.
Create an account or sign in to comment