WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] posts_nav_link issue (6 posts)

  1. wizardfusion
    Member
    Posted 3 years ago #

    Can someone confirm what I am seeing please...

    I have the following code in a search results page...

    <div class="alignleft"><?php posts_nav_link('','','Previous') ?></div>
    <div class="alignright"><?php posts_nav_link('','Next','') ?></div>

    As you can see the posts_nav_link has two missing options for each line. In the first, I am missing "sep" and "prelabel". In the second I am missing the "sep" and "postlabel". I am sure you can see why.

    The results I am getting are...
    « Previous Page — Previous and Next — Next Page »
    If I replace the missing options for spaces, I get the correct result of Previous and Next

    It's not an issue as such, but the documentation does say optional, which is why is confused me.

    This can be seen on my 3.0.5 site too...
    http://blog.myimagegallery.co.uk/index.php?s=e
    This search results page shows two nav sections at the bottom. The first one is with spaces added, the second without.

    Thanks.

  2. Andrew Nacin
    Lead Developer
    Posted 3 years ago #

    Yeah, the function treats an empty string as an argument that was not supplied, thus the defaults are used. This is very unlikely to change, as the function has been like this way probably since its introduction, in WordPress 0.71.

  3. wizardfusion
    Member
    Posted 3 years ago #

    Thanks, can someone change the documentation then please. :)

  4. Andrew Nacin
    Lead Developer
    Posted 3 years ago #

    The Codex is editable -- just use the login you used to access the forums. :-)

  5. wizardfusion
    Member
    Posted 3 years ago #

    ah, I was looking at the documentation at http://phpdoc.wordpress.org/trunk/WordPress/Template/_wp-includes---link-template.php.html#functionposts_nav_link
    as this is linked to via the lookup button in the wordpress editor.

  6. wizardfusion
    Member
    Posted 3 years ago #

    Not to worry, on the codex page, my exact code block is listed with "this is poor code..."!

    I'll change my code.
    Thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic