WordPress.org

Ready to get started?Download WordPress

Forums

How to add a #marker in php next_posts_link? (11 posts)

  1. baal666
    Member
    Posted 4 years ago #

    Hi,

    I'd like to get a link to a particular #marker somewhere on the page when people are trying to access my previous posts. How can it be done?

    I tried:

    <a href="#marker"><?php next_posts_link('&laquo; Billets pr&eacute;c&eacute;dents') ?></a>

    and

    <?php next_posts_link('<a href="#marker">&laquo; Billets pr&eacute;c&eacute;dents</a>') ?>

    but it was a failure.

    Any idea?

    Thanks

  2. MichaelH
    Member
    Posted 4 years ago #

    Could use get_next_posts_link then use str_replace to put that marked in the link the use echo to display the link.

    Also could modify the function get_next_posts_link in wp-includes/link-template.php but modifying core code is discouraged.

    Then again there might be a filter for that but darned if I can see it...

  3. baal666
    Member
    Posted 4 years ago #

    Hmmm... I'm kind of a newbie... Any easier way to integrate a # marker?

  4. MichaelH
    Member
    Posted 4 years ago #

    Not unless you can find a plugin.

    Maybe wp-pagenavi has something. http://wordpress.org/extend/plugins/wp-pagenavi/

  5. baal666
    Member
    Posted 4 years ago #

    I hate plugins; they slow down my blog so much.

  6. baal666
    Member
    Posted 4 years ago #

    How would you use str_replace to idenfify a # marker in the next page?

  7. MichaelH
    Member
    Posted 4 years ago #

    Actually get_next_posts_link returns a link such as this:

    <a href="http://sample.com/?paged=3" >&laquo; Older Entries</a>

    So you want to link to look like?

  8. baal666
    Member
    Posted 4 years ago #

    Hmmm... Not sure to understand. Whay I need is to relate to the next page but at a particular place in that page, on the place.

  9. MichaelH
    Member
    Posted 4 years ago #

    but at a particular place in that page

    Ah I got you. But, the next page is a series of posts so every next/previous page will have a different set of posts.

  10. baal666
    Member
    Posted 4 years ago #

    Yes, I understand that, but I want to put a # marker on them so it will show the right place.

  11. MichaelH
    Member
    Posted 4 years ago #

    Okay, then put the marker in place and type the URL in your browser that goes to that marker then report that URL back here.

Topic Closed

This topic has been closed to new replies.

About this Topic