May be this is an easy question for most but i couldn't do it. I just want to add a link an my Post Page (wordpress) and when a visitor clicks it he or she must go the comments part of that page. Something like this: <a href="mywebsite. com/sample-post/#comments"> Leave a Comment </a> But, i will add this code to the single-content.php so what should i write instead of this: mywebsite. com/sample-post/ So when i add the code to single.php file once, then it will take visitors to the comments section of every single page.. Thanks.
I'm confused... why don't you just do <a href="#comments">Leave a comment</a>? If you're gonna use this on the specific page the user is already on, why use a full link, when just the #comments works? If you want someone to be able to go to the comments-section for specific pages from other pages, that's a different story.
Set the id attribute of your <div> element containing the comments as as comments Then for your button, use something like this: <a href="#comments" class="btnScrollToComments">Goto Comments</a> And in jQuery code: $(function(){ $(".btnScrollToComments").click(function() { $('html, body').animate({ scrollTop: $("#comments").offset().top }, 2000); }); }); Code (JavaScript): This will give you a smooth effect of scrolling. Hope this helps.
That's almost worked. Thank you. But have a little problem. The page that i will use this code is the AMP page. And i want visitors to go to the non-AMP page. So your code worked but still sending the visitor to the same AMP Page.. So what must do for sending them to the non/AMP page of the page? Ps: I am using this code on AMP content-single.php
Correcting and simpling my question: how to direct my AMP page to Non-AMP page? Which code will be useful?