Support » Fixing WordPress » Next and Previous Links Add to #top to URL structure?

  • On the next and previous links I want to add onto them.

    For example:

    <?php next_post( '%', 'Next', '' ) ?>

    Will output:

    <a href="http://mysite.com">Next</a>

    I want it to output

    <a href="http://mysite.com/#top">Next</a>

    Where are the core files to edit to enable me to hack this?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    next_post() is deprecated – replace with http://codex.wordpress.org/Template_Tags/next_post_link

    try to use a filter function, added to fuctions.php of your theme;

    example:

    add_filter('next_post_link','add_anchor_to_adjacent_post_link');
    add_filter('previous_post_link','add_anchor_to_adjacent_post_link');
    function add_anchor_to_adjacent_post_link($link) {
    $link = str_replace('" rel','#top" rel',$link);
    return $link;
    }

    That worked perfect for adding anchors to next and previous links.

    Now my website visitors may stay longer.

    Good work.

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Next and Previous Links Add to #top to URL structure?’ is closed to new replies.