Support » Fixing WordPress » Editing next_posts_link & previous_posts_link

  • Hey there I’m working on a custom theme and have an issue with next_posts_link & previous_posts_link that is really bugging me.

    If we look at this snippet of navigation that appears on the single.php page:

    <div class="navigation">
    	<div class="alignleft"><?php previous_post_link('&laquo; %link') ?></div>
    	<div class="alignright"><?php next_post_link('%link &raquo;') ?></div>

    When WordPress renders this code. The hyperlink does not wrap around “«” and only wraps around what is generated by “%link”.

    This is FINE, this is what I want. Now if we look at this second snippet of code, taken from my index.php file:

    <div class="navigation">
    <div class="alignleft"><?php next_posts_link('&laquo; Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries &raquo;') ?></div>

    Now the markup is nearly identical, with the exception of “%link” being replaced with “Older Entries” & “Newer Entries”.

    For some reason WordPress will render this bit of code with the hyperlink wrapping around “«”

    I don’t like this and want to make it render the “«” outside of the hyperlink as it does in the other circumstances.

    Where can I modify this?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Would it be as simple as:

    <div class="navigation">
    <div class="alignleft">&laquo;<?php next_posts_link('Older Entries') ?></div>
    <div class="alignright"><?php previous_posts_link('Newer Entries') ?>&raquo;</div>

    No it’s not, I actually should have specified it. Your method is the reason I’m looking to edit the actual function. Moving the “«” outside of the PHP code will make it render all the time. While leaving it in where it is, it’s only drawn into your page when there are older or newer posts.

    That’s why I’d like to try and find where WordPress draws all this up, so I can move the quote outside of the hyperlink.

    how about:

    if (next_posts_link()){
    echo '<div class="alignleft">&laquo;'.next_posts_link('Older Entries').'</div>

    I would avoid modifying the actual WP source. Every time there is an update you may neeed to re-edit the code.


    actually next_posts_link may always return TRUE, not sure. Need to check later.

    sorry that should say:
    actually next_posts_link may NOT always return TRUE, not sure. Need to check later.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Editing next_posts_link & previous_posts_link’ is closed to new replies.