[resolved] Making link_pages reference an anchor (4 posts)

  1. Jonathan Landrum
    Posted 9 years ago #

    The problem I'm having is that my style has a rather large gap between the header and the content, so if you're on a paged article and click a link to another page, you have to scroll down to get back to the article. What I wanted to do is have <?php link_pages() ?> or <?php wp_link_pages() ?> link to the next page #post or whatever.

    There seems to be a way to make the tag do what I need, but I'm having difficulty getting my syntax right. I searched the Codex and found this parameter:

    (string) Page the links should point to. Defaults to the current page.

    Unfortunately I'm just not getting it. Here's what I've got so far:
    <?php wp_link_pages('before=<p class="pagination">Pages: &after=</p>&next_or_number=number&more_file=#post'); ?>

    I've even tried <?php ... &more_file=( the_permalink() )#post'); ?>. Any ideas?

  2. Jonathan Landrum
    Posted 9 years ago #

    Found this on Trac: http://trac.wordpress.org/ticket/3119
    It could be easily modified to do what I need. How would I make it into a plugin so I wouldn't have to modify core code at every update?

  3. Kafkaesqui

    Posted 9 years ago #

    If you have the basics of writing a plugin down, you could modify the name of the function when defining it, from:

    function link_pages(

    to something like:

    function enhanced_link_pages(

    then just call that in your theme template(s), rather than link_pages().

  4. Jonathan Landrum
    Posted 9 years ago #

    I gave up and modified the core file. :o\ But thanks, though. I'll just have to remember that at the next update. Besides, it's only necessary because of my theme. Who's to say I won't be using it when update time comes around? Thanks again, Kafkaesqui. You're always very helpful.

Topic Closed

This topic has been closed to new replies.

About this Topic