Is there any way of appending a variable onto the URL generated by the next_post_link function?
next_post_link('%link', 'Next', FALSE, '1');
As is stands, this would link to, for example:
http://mysite.com/films/oliver-twist/
When I need it to link to:
http://mysite.com/films/oliver-twist/?new=1
from certain pages.
Any help appreciated!
I dont think you can do it with next_post_link. try it with get_adjacent_post.
something like this:
<?php
$next_post = get_adjacent_post( false, '', false );
$previous_post = get_adjacent_post( false, '', true );
if($previous_post) : ?>
<a href="<?php echo get_permalink($previous_post->ID); ?>?new=1"><?php echo get_the_title($previous_post->ID) ?></a>
<?php php endif; ?>
<?php if($next_post) : ?>
<a href="<?php echo get_permalink($next_post->ID); ?>?new=1"><?php echo get_the_title($next_post->ID) ?></a>
<?php php endif; ?>
Hi traumm, instead of next_post_link, have you tried the get_next_posts_link function? I believe this is a similar thread:
[resolved] Next and Previous Posts URLs
I ended up get_adjacent_post in the end - it's working fine now!
Thanks both!