I am using the below code to display my next and previous links in single.php:

<div class="nav-previous"><?php previous_post_link( '%link', '<img height="34" src="' . get_bloginfo("template_directory") . '/images/previous.png" />' ); ?></div>
    <div class="nav-next"><?php next_post_link( '%link', '<img height="34" src="' . get_bloginfo("template_directory") . '/images/next.png" />' ); ?></div>

Everything is working well except that I am defining some rewrite rules in my websites so I am not using the default links like:


but instead


I managed to change the structures of my links for all the website except for the next and previous links, since it requires maybe change of core code!!

How can I customize the urls returned by these two Wordpress functions?

Thanks for your time and consideration.


I am using custom post type(=aya-bi-aya).My permalink structure is set to default. It then displays my permalinks like:


But inside my website, I dont need such urls, but instead I am using urls like:


The additional parameters fulfill my needs, especially in my jquery code. Plus, I am using the mod_rewrite to tranform my links to:


The only remaining thing is to change the links in previous and next, so that they respect this last shape.

Thanks Milo for triggering the real issue.

  • 2
    This can help you. wordpress.stackexchange.com/questions/46761/… – Vinod Dalvi Aug 28 '13 at 17:37
  • 1
    those functions ultimately use get_permalink to output the links, how are you outputting the correct links for single posts? are these a custom post type? if you correctly filter post_link or post_type_link to format your URLs, this problem will disappear, but I have a feeling you've gone about the whole thing in a strange way to end up where you are now. – Milo Aug 28 '13 at 18:15
  • @whitelettersandblankspaces If you found any solution then add it here as an answer and accept it. – Vinod Dalvi Aug 28 '13 at 18:40
  • @Milo: I am using the default permalink structure for my custom post type (aya-bi-aya) + other params that I am not including in my question, I am giving an edit. I am trying to understand the idea about post_link and post_type_link. thanks – whiteletters in blankpapers Aug 28 '13 at 18:41
  • @VinodDalvi of course. I am still reading your link and trying to understand Milo comment – whiteletters in blankpapers Aug 28 '13 at 18:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.