Tagged: blog post, pagination
hello,
I have added latests news on our home page here https://napocatku.affe.cz/#novinky but when I click on next page (2, 3) it redirects me to https://napocatku.affe.cz/page/2/ or https://napocatku.affe.cz/page/3/ etc.
However, I would like to stay in the same element (section) so something like https://napocatku.affe.cz/#novinky-2 I don’t want to scroll down every time I want to read earlier news.
Thanks
Michal
Hey cukrmi,
Sorry for the late reply, the only way I could find to change this is to append your section ID to the pagination links with jQuery.
Try adding this code to the end of your functions.php file in Appearance > Editor:
function custom_pagination_script(){
?>
<script>
(function($){
$(document).ready(function(){
$(".pagination-wrap.pagination-slider nav.pagination a").each(function() {
var $this = $(this);
var _href = $this.attr("href");
$this.attr("href", _href + '#novinky');
});
});
})(jQuery);
</script>
<?php
}
add_action('wp_footer', 'custom_pagination_script');
also please ensure that this theme setting is disabled: Enfold Theme Options > Performance > Load jQuery in your footer
Best regards,
Mike
This works wonderfully.
Perfect!
Thank you.
Hi,
Great, I’m glad that Mike could help you out. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
Rikard
You can close this thread now.