Forums

Editing next_posts_link & previous_posts_link (7 posts)

  1. Michael
    Member
    Posted 3 years ago #

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

  2. willmacdonald
    Member
    Posted 3 years ago #

    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>
    </div>
  3. Michael
    Member
    Posted 3 years ago #

    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.

  4. willmacdonald
    Member
    Posted 3 years ago #

    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.

    W

  5. willmacdonald
    Member
    Posted 3 years ago #

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

  6. willmacdonald
    Member
    Posted 3 years ago #

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

  7. willmacdonald
    Member
    Posted 3 years ago #

Topic Closed

This topic has been closed to new replies.

About this Topic