I have this anchor link in my index.php:
<a name="blog"></a>
I would like this anchor link to work When next_posts_link and previous_posts_link are clicked on so it doesn't go all the way to the top of the page. I have no idea how to go about doing this for WordPress pagination though.
Here is my code for the pagination:
<div class="pagenavi">
<?php if( function_exists( 'wp_pagenavi ' ) ) {
wp_pagenavi();
} else {
next_posts_link ('<div class="arrow-back"></div>'); }
previous_posts_link('<div class="arrow-forward"></div>') ; }
unfortunately the wp_pagenavi function seems to encapsulate the complete link building.
If you can't configure a generic postfix in your wordpress or plugin configuration I don't recommend to change Wordpress code.
Instead you could execute a small JavaScript which moves the browser page to the anchor on load.
This example uses jQuery. Paste it into a bottom location of your template.
Couldn't test this but should work. Even simple scripts are the hell to write on a iPhone keyboard..
EDIT: Works like a charm, check this out for a demo http://jsfiddle.net/mfeldheim/EkMfP/7/
Solution 2:
Adding anchor tag #blog to the prev/next links in a blogpost using jQuery
Demo: http://jsfiddle.net/mfeldheim/EkMfP/12/