• Hello!

    I have a gallery that shows 9 thumbnails per page, and is often paginated. In instances where there is a filter passed to the query, I am having the page shift down to a named anchor (#togallery) so that the user sees the content rather than all the header stuff.

    No problems there, except that when it paginates (using next_posts_link) the anchor does not carry over, and I’d like it to, if possible.

    Does anyone have any ideas about how to achieve this? I’d be grateful for any pointers.

    Thanks

    John

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’m looking for the same thing.

    riki81

    (@riki81)

    Check this!

    <?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 ?>

    It is valid for next-posts() and previous_posts(), typical in HOME PAGE, but not for next_post_link() and previous_post_link(), both used in SINGLE POST template.
    I’m looking for the same solution, but for SINGLE POST page navigation (from one post to another one).

    Hope has been useful! 😉

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Passing an linked anchor through pagination?’ is closed to new replies.