• Hi, I need to let the user jump directly to an exact point navigating from post1 to post2, etc.
    Normally, I use:

    <div class="navigation_previous"><?php next_post_link( '%link', __( '&laquo;', 'twentyeleven' ) ); ?></div>
    <div class="navigation_next"><?php previous_post_link( '%link', __( '&raquo;', 'twentyeleven' ) ); ?></div>

    but this give in out put sth like https://DOMAIN/?p=POSTID
    What I really need id https://DOMAIN/?p=POSTID#anchor to let the user open the post directly at the correct level of the page.

    Thanks to everyone can help me! Greetings!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator t-p

    (@t-p)

    see if info in this thread helps.

    Thread Starter riki81

    (@riki81)

    Thanks for quick reply!
    I knew that thread, and I used it a lot for POSTS navigation (normally used in home page) with “previous_posts_link”, etc… but I need to do the same for SINGLE POST page with “previous_post_link”.

    It sounds ridiculous, but actually it seems so different! ??

    Waiting for someone help!!! Thanks t-p! ??

    Moderator t-p

    (@t-p)

    Thread Starter riki81

    (@riki81)

    Hi, I’ve checked, but nothing… the problem is that previous_post_link generates entire link, so I am not able to do sth like previous_post_link#anchor.

    For HOME I did:

    <?php
                                    $the_last_page = $wp_query->max_num_pages;
                                    $loaded_page = intval($paged);
                                ?>
                                <?php if ( $the_last_page == $loaded_page) { // if is the last page ?>
                                    <div class="navigation_previous"><a href="<?php previous_posts(); ?>#box2">&laquo;</a></div>
                                <?php } elseif ($loaded_page == 0) { // if is home ?>
                                    <div class="navigation_next"><a href="<?php next_posts(); ?>#box2">&raquo;</a></div>
                                <?php } else { //otherwise ?>
                                    <div class="navigation_previous"><a href="<?php previous_posts(); ?>#box2">&laquo;</a></div><div class="navigation_next"><a href="<?php next_posts(); ?>#box2">&raquo;</a></div>
                                <?php }  // links to newer and older posts ?>

    but for single one I cannot do, ’cause previous_post is deprecated function! ??

    Any other solution? Maybe a good programmer, looking at previous code I’ve shared above, could think sth of useful for my situation… ??

    Thanks a lot!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘next_post_link(); with anchor’ is closed to new replies.